I need to list all unique product-options within a Shopify store using the GraphQL API. However, I’m unable to do so and can’t find the solution in the API docs.
Currently, I can query all product-options in the store using GraphQL-query:
query {
translatableResources(first:250, resourceType:PRODUCT_OPTION) {
nodes {
resourceId,
translatableContent {
key,
locale,
type,
value
}
}
}
}
This returns me a list with the product-options. However, the options are returned for each product, therefore this list can be very long when the store has many products. For example, I get the product-option ‘Kleur’ meaning Color multiple times, as multiple products have this option:
[resourceId] => gid://shopify/ProductOption/10539451875649
[translatableContent] => Array
(
[0] => Array
(
[key] => name
[locale] => nl
[type] => SINGLE_LINE_TEXT_FIELD
[value] => Kleur
)
)
[resourceId] => gid://shopify/ProductOption/10543580086593
[translatableContent] => Array
(
[0] => Array
(
[key] => name
[locale] => nl
[type] => SINGLE_LINE_TEXT_FIELD
[value] => Kleur
)
)
As you can see, the same value ‘Kleur’ is returned for two different product option id’s. As said, I want to prevent a huge list which requires pagination to be processed depending on the number of products (with these product-options enabled).
Therefore, I’m looking for a GraphQL-query that returns me the unique product-option values, but I can’t find it anywhere in the docs.