排序列表查询
可以使用 sort 参数对查询结果进行排序。通过为字段名称指定 ASC 或 DESC 来设置排序顺序(升序与降序)。
在以下示例中,我们有一个名为 students 的表,其中包含诸如 createdAt、firstName、email 等字段和关系。
在查询中使用排序
Section titled “在查询中使用排序”这是一个查询,结果将按创建日期的升序排列。
请求
query MyQuery1 { students(sort: [CREATEDAT]) { items { id createdAt firstName email } }}响应
{ "data": { "students": { "items": [ { "id": "287cff0a-345b-4cca-9e9a-75a2161238fd", "createdAt": "2025-12-02T05:01:31.054581Z", "firstName": "James", "email": "james.smith@example.com" }, { "id": "97fb89ac-e0ad-44f5-b671-24a1b751287c", "createdAt": "2025-12-02T05:03:17.180675Z", "firstName": "John", "email": "john.williams@example.com" }, { "id": "429cf99f-4481-49c4-adb4-605731b20eb2", "createdAt": "2025-12-04T14:16:53.049955Z", "firstName": "Mary", "email": "mary.brown@example.com" } ] } }}嵌套和多字段排序
Section titled “嵌套和多字段排序”您的查询结果可以按相关表上的属性排序,也可以使用多个排序对象。它们按接收到的顺序按优先级排序。