A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I have this piece of GraphQL query:
query AllProductTypes ($cursor: String) { productTypes(first: 250, after: $cursor) { edges { node cursor } pageInfo { hasNextPage } } }
Error: Field 'productTypes' doesn't accept argument 'after'
is it possible that the after is not available for this specific query? Anyone has any workaround?
The ironic thing is, if we remove after the query returns everything fine with cursors as well. hasNextPage always returns false no matter what is the return limit. So if I put a lesser limit it will return false as well.
Not sure what's going on here. Any help would be appreciated. Thanks!
Hi Mladen,
From the error message, it seems like the after
argument is not accepted by the productTypes
query in your GraphQL schema. It's possible that this specific query does not support cursor-based pagination, or the pagination is implemented differently.
I see there is a possible return of StringConnection.pageInfo
for which is intended to help with pagination on the productTypes
field. Could you use this to paginate the returned data?
Hope this helps!
Liam | Developer Advocate @ 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
Hi Liam, thanks for your reply.
No that is not helpful. If I cannot use "after" in the query, I think pagination is useless here.
Do you know of any other way to fetch ALL product types?