分页查询
在以下示例中,我们有一个名为 students 的表,其中包含诸如 firstName、email、age 等字段和关系。
在查询中使用分页
Section titled “在查询中使用分页”参数 skip 和 first 用于分页。
first 指定从结果集中传递的行数,skip 确定从结果中保留哪个切片。
请求
query MyQuery1 { /** * First consider 0 as the starting slice of paginated records. As this * number is increased, the prior results leave out previously fetched * records. (i.e., skip 0 -> skip 3 -> skip 6 -> skip 9...) */ students(skip: 0, first: 3,) { items { id firstName email age } }}响应
{ "data": { "students": { "items": [ { "id": "287cff0a-345b-4cca-9e9a-75a2161238fd", "firstName": "James", "email": "james.smith@example.com", "age": 22 }, { "id": "97fb89ac-e0ad-44f5-b671-24a1b751287c", "firstName": "John", "email": "john.williams@example.com", "age": 23 }, { "id": "429cf99f-4481-49c4-adb4-605731b20eb2", "firstName": "Mary", "email": "mary.brown@example.com", "age": 24 } ] } }}