I am currently building out a storefront using React and Hydrogen. I am trying to access all types that are used in a collection. The collection object in the Liquid API does return the "all_types" field that lists the desired information. However, the Storefront API GraphQL endpoint does not return this attribute. Am I missing something? Also, if there really are differences between the data than can be returned I'd be curious to know why this distinction is being made.
Thanks in advance!
In this case you can get a list of product types with Storefront API GraphQL like this:
In the collection object there is a connection with products it contains and the product object has a property called productType.
Please refer to the following documentations:
https://shopify.dev/docs/api/storefront/2023-10/objects/Collection https://shopify.dev/docs/api/storefront/2023-10/objects/Product
{
collection(id: "gid://shopify/Collection/<YOUR_COLLECTION_ID>") {
products(first: 250) {
edges {
node {
productType
}
}
}
}
}