Development discussions around Shopify APIs
I am trying to use GraphQL to retrieve various information about my orders. My GraphQL schema basically looks like this:
query order {
orders(before: "2021-11-02", after: "2021-01-01") {
edges {
node {
app {
name
}
But I am getting the following error:
you must provide one of first or last
Why is this and how can I get around it? I just want my search results to be filtered by a date period rather than a set count that I have to enforce.
Solved! Go to the solution
This is an accepted solution.
Hi @jlarks32
The before and after parameters limit the range of results, whereas the first/last parameter determines how many results from that range to return at a time, and whether to start at the beginning of the set or the end. This is needed if you're going to paginate through results. Imagine that you have 1500 orders during the 11 month period that you're querying. You can't return all 1500 orders in a single response, so you need to specify how many orders to return at a time, and whether to start with oldest first or newest first. You can read more about how this works in our GraphQL documentation and there is also a post on the partners blog with accompanying video here: https://www.shopify.ca/partners/blog/graphql-pagination
Best,
CS | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
This is an accepted solution.
Hi @jlarks32
The before and after parameters limit the range of results, whereas the first/last parameter determines how many results from that range to return at a time, and whether to start at the beginning of the set or the end. This is needed if you're going to paginate through results. Imagine that you have 1500 orders during the 11 month period that you're querying. You can't return all 1500 orders in a single response, so you need to specify how many orders to return at a time, and whether to start with oldest first or newest first. You can read more about how this works in our GraphQL documentation and there is also a post on the partners blog with accompanying video here: https://www.shopify.ca/partners/blog/graphql-pagination
Best,
CS | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
User | RANK |
---|---|
49 | |
16 | |
9 | |
7 | |
5 |
Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023One of the key components to running a successful online business is having clear and co...
By Ollie Mar 6, 2023