From 177a9baf5574a20f361b0e50c7ffc855c07c69ea Mon Sep 17 00:00:00 2001 From: Brian Beck Date: Sat, 26 Nov 2016 12:03:46 -0800 Subject: [PATCH] Add pagination example --- README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/README.md b/README.md index 3f157b0..aa7ca65 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ to help construct your query. - [Environment Variables](#environment-variables) - [Debugging](#debugging) - [Example Queries](#example-queries) + - [Pagination](#pagination) - [Questions](#questions) - [Schema](#schema) @@ -143,6 +144,49 @@ Nirvana albums and each album’s singles: } ``` +### Pagination + +The first five labels with “Apple” in the name: + +```graphql +{ + search { + labels(query: "Apple", first: 5) { + ...labelResults + } + } +} + +fragment labelResults on LabelConnection { + pageInfo { + endCursor + } + edges { + cursor + node { + mbid + name + type + area { + name + } + } + } +} +``` + +…and the next five, using the `endCursor` from the previous result: + +```graphql +{ + search { + labels(query: "Apple", first: 5, after: "YXJyYXljb25uZWN0aW9uOjQ=") { + ...labelResults + } + } +} +``` + ## Questions **What’s with the cumbersome `edges`/`node` nesting? Why `first`/`after`