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 |
---|---|
6 | |
5 | |
5 | |
5 | |
4 |
Learn these 5 things I had to learn the hard way with starting and running my own business
By Kitana Jan 27, 2023Would you love to unleash the unbridled power of the Google Shopping Channel into your sho...
By Gabe Jan 6, 2023How can you turn a hobby into a career? That’s what Emmanuel did while working as a wa...
By Skye Dec 30, 2022