All things Shopify and commerce
Hi All,
The regular query to have a referenced product from the metafield works in Shopify GraphQL App.
Reault query:
query cartTramsforms { cartTransforms(first: 10) { edges { node { id functionId metafields(first: 10) { edges { node { namespace key value reference { ... on Product { id title } } } } } } } } }
Output:
{ "data": { "cartTransforms": { "edges": [ { "node": { "id": "gid://shopify/CartTransform/22118573", "functionId": "5757998b-132a-4c93-b076-857bb0d7ebfb", "metafields": { "edges": [ { "node": { "namespace": "custom", "key": "bundle_parent", "value": "gid://shopify/Product/8029330997421", "reference": { "id": "gid://shopify/Product/8029330997421", "title": "Meal Bundle" } } }, { "node": { "namespace": "custom", "key": "json_data", "value": "{\"key\":\"value\"}", "reference": null } } ] } } } ] } }, "extensions": { "cost": { "requestedQueryCost": 46, "actualQueryCost": 7, "throttleStatus": { "maximumAvailable": 2000, "currentlyAvailable": 1993, "restoreRate": 100 } } } }
When I put the same metafield reference in the input query of the Shopify Function Extension, it says [FAILED] Error 0: Cannot query field "reference" on type "Metafield".
Input Query:
query RunInput { cart { lines { id quantity ## Properties Values custom_data: attribute(key: "_custom_data") { value } merchandise { __typename ... on ProductVariant { product { id title } } } } seed_attribute: attribute(key: "_bundles") { value } } cartTransform { # Access the product referenced by the bundle_parent metafield bundle_parent: metafield(namespace: "custom", key: "bundle_parent") { value reference { ... on Product { id title handle } } } } }
What should I do to get the referenced product information in the input query?
Appreciate any input, thanks.
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025