A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I have an app that creates discount codes, similar to the app described in this tutorial: https://shopify.dev/apps/discounts/create
These discounts are created as codeAppDiscounts. I would like to be able to query this with GraphQL and access the private metafields. The metafields are created with a given namespace and key.
I've tried a query like this but getting 500 errors back.
Query
{ discountNodes(first: 1) { edges { node { id privateMetafield(namespace: "my-namespace", key: "my-key") { value } } } } }
Error:
{ "errors": [ { "message": "Internal error. Looks like something went wrong on our end.\nRequest ID: cb1f7743-b8f5-4cc5-9aeb-856a32385667 (include this in support requests).", "extensions": { "code": "INTERNAL_SERVER_ERROR", "requestId": "cb1f7743-b8f5-4cc5-9aeb-856a32385667" } } ] }
Any ideas what is going wrong or how I might access these metafields? Thanks!
Solved! Go to the solution
This is an accepted solution.
Mistake on my part - this should just use metafield instead of private metafield
metafield(namespace: "my-namespace", key: "my-key") { value }
This is an accepted solution.
Mistake on my part - this should just use metafield instead of private metafield
metafield(namespace: "my-namespace", key: "my-key") { value }