Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Query App Discount Code Private Metafields

Solved

Query App Discount Code Private Metafields

alecbarnard
Shopify Partner
2 1 2

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!

Accepted Solution (1)

alecbarnard
Shopify Partner
2 1 2

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
        }

View solution in original post

Reply 1 (1)

alecbarnard
Shopify Partner
2 1 2

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
        }