How to fetch ALL Product Types

How to fetch ALL Product Types

Mladen_Terzic
Shopify Partner
18 1 4
 

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!

 
Shopify Expert
Replies 2 (2)

Liam
Shopify Staff
2873 312 821

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

Mladen_Terzic
Shopify Partner
18 1 4

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?

Shopify Expert