{"action":"created","issue":{"url":"https://api.github.com/repos/Shopify/js-buy-sdk/issues/386","repository_url":"https://api.github.com/repos/Shopify/js-buy-sdk","labels_url":"https://api.github.com/repos/Shopify/js-buy-sdk/issues/386/labels{/name}","comments_url":"https://api.github.com/repos/Shopify/js-buy-sdk/issues/386/comments","events_url":"https://api.github.com/repos/Shopify/js-buy-sdk/issues/386/events","html_url":"https://github.com/Shopify/js-buy-sdk/issues/386","id":241626740,"number":386,"title":"Documentation on pagination","user":{"login":"doublerebel","id":212827,"avatar_url":"https://avatars3.githubusercontent.com/u/212827?v=3","gravatar_id":"","url":"https://api.github.com/users/doublerebel","html_url":"https://github.com/doublerebel","followers_url":"https://api.github.com/users/doublerebel/followers","following_url":"https://api.github.com/users/doublerebel/following{/other_user}","gists_url":"https://api.github.com/users/doublerebel/gists{/gist_id}","starred_url":"https://api.github.com/users/doublerebel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doublerebel/subscriptions","organizations_url":"https://api.github.com/users/doublerebel/orgs","repos_url":"https://api.github.com/users/doublerebel/repos","events_url":"https://api.github.com/users/doublerebel/events{/privacy}","received_events_url":"https://api.github.com/users/doublerebel/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-07-10T07:47:39Z","updated_at":"2017-07-10T14:05:35Z","closed_at":"2017-07-10T14:05:35Z","body":"Hello,\r\n\r\nIs there official documentation for pagination?  I have read in #221 and #369 that total count is not available, but it took me quite a while to realize that `fetchAllProducts` doesn't actually fetch _all_ products, just the first 20 and the rest are paginated.  There is a lot of discussion about fetching in #148 but I'm not sure if that is current with 1.0alpha.\r\n\r\n- Are all sets paginated?\r\n- Is it the same number per page for all sets (20)?\r\n- Is this the correct way to page through a set?\r\n```js\r\nvar products = await shopify.fetchAllProducts()\r\n// products contains up to 20 products\r\n\r\nvar moreProducts = await client.graphQLClient.fetchNextPage(products)\r\n// moreProducts.model contains next page of up to 20 products starting at #21\r\n```\r\nPagination added in #300 and #314 gave me the first clue, but there is no pagination in the shopify-buy library (P.S. developing and publishing on alpha branch and not master makes it difficult to search the code without downloading the whole library source).\r\n\r\nSo I inspected the products and the product items are actually a GraphModel.  Googling for GraphModel gives me [an empty doc](https://shopify.github.io/graphql-js-client/GraphModel.html) but on the GraphModel objects are a function `nextPageQueryAndPath`.  Google only shows [a single result for `nextPageQueryAndPath`](https://www.google.com/search?q=nextpagequeryandpath), [the source to the GraphQL client](https://shopify.github.io/graphql-js-client/client.js.html), where luckily I found `fetchNextPage`.  `fetchNextPage` seems to work fine.\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/Shopify/js-buy-sdk/issues/comments/314115784","html_url":"https://github.com/Shopify/js-buy-sdk/issues/386#issuecomment-314115784","issue_url":"https://api.github.com/repos/Shopify/js-buy-sdk/issues/386","id":314115784,"user":{"login":"minasmart","id":568174,"avatar_url":"https://avatars3.githubusercontent.com/u/568174?v=3","gravatar_id":"","url":"https://api.github.com/users/minasmart","html_url":"https://github.com/minasmart","followers_url":"https://api.github.com/users/minasmart/followers","following_url":"https://api.github.com/users/minasmart/following{/other_user}","gists_url":"https://api.github.com/users/minasmart/gists{/gist_id}","starred_url":"https://api.github.com/users/minasmart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minasmart/subscriptions","organizations_url":"https://api.github.com/users/minasmart/orgs","repos_url":"https://api.github.com/users/minasmart/repos","events_url":"https://api.github.com/users/minasmart/events{/privacy}","received_events_url":"https://api.github.com/users/minasmart/received_events","type":"User","site_admin":false},"created_at":"2017-07-10T14:05:35Z","updated_at":"2017-07-10T14:05:35Z","body":"`GraphModel` is empty by design. It's extendable, but it's mostly an object proxy. v1 of Shopify Buy is really just a thin layer on top of our graphql client, and our storefront API. Pagination, at the API level, uses the [relay connection specification](https://facebook.github.io/relay/graphql/connections.htm), which is wrapped up nicely by `graphql-js-client` using [fetchNextPage](https://shopify.github.io/graphql-js-client/Client.html) (part way down the page). There's also an example [here](https://github.com/Shopify/graphql-js-client#pagination). We absolutely need a better way to expose pagination at the top level of this library, but until then, your approach is correct."}}
{"actor":{"display_login":"minasmart"}}