How to retrieve objects referenced by GID in Shopify Storefront API?

I’m relatively new to the Storefront API and working on retrieving metafields from my products. While I’ve managed to extract the key names, I’m struggling with extracting the values, particularly when they reference other objects via GID. I can see the GIDs, but I'm unsure how to fetch the objects these GIDs reference. Here’s the Admin API query I’m using: { products(first: 1) { edges { node { metafields(first: 10) { __typename edges { node { id key value } } } } } } } This returns the following data: { "data": { "products": { "edges": [ { "node": { "metafields": { "__typename": "MetafieldConnection", "edges": [ { "node": { "id": "gid://shopify/Metafield/52045884293444", "key": "color-pattern", "value": "[\"gid://shopify/Metaobject/85932474692\"]" } }, { "node": { "id": "gid://shopify/Metafield/52045884326212", "key": "power-source", "value": "[\"gid://shopify/Metaobject/85932376388\"]" } }, { "node": { "id": "gid://shopify/Metafield/52045884358980", "key": "detector-type", "value": "[\"gid://shopify/Metaobject/85932409156\"]" } }, { "node": { "id": "gid://shopify/Metafield/52045884391748", "key": "mounting-type", "value": "[\"gid://shopify/Metaobject/85932540228\",\"gid://shopify/Metaobject/85932507460\",\"gid://shopify/Metaobject/85932441924\"]" } }, { "node": { "id": "gid://shopify/Metafield/54392438554948", "key": "brand", "value": "gid://shopify/Metaobject/91629715780" } } ] } } } ] } }, "extensions": { "cost": { "requestedQueryCost": 9, "actualQueryCost": 8, "throttleStatus": { "maximumAvailable": 2000, "currentlyAvailable": 1992, "restoreRate": 100 } } } } My question is: How should I proceed with the API to retrieve the actual objects referenced by these GIDs (such as the metaobjects) instead of just seeing the GID strings? Any advice or examples would be greatly appreciated.

Comment (0)

You’ll be in good company