Why can't I view my app-data metafields with graphql?

Why can't I view my app-data metafields with graphql?

wil_dev
Shopify Partner
12 0 2

Hi there,

I can't see my app-data metafields if I use graphql

but I CAN see it on my app embed block... with  = > {{app.metafields.super_cart_metafields.div.value}}

/// CREATING MY METAFIELD, IT WORK
const response = await admin.graphql(
      `#graphql
      mutation CreateAppDataMetafield($metafieldsSetInput: [MetafieldsSetInput!]!) {
        metafieldsSet(metafields: $metafieldsSetInput) {
          metafields {
            id
            namespace
            key
          }
          userErrors {
            field
            message
          }
        }
      }`,
      {
        variables: {
          metafieldsSetInput: {
            namespace: "super_cart_metafields",
            key: "div",
            type: "single_line_text_field",
            value: "F",
            ownerId: id
          }
      }}
    )
///// RETRIEVE MY METAFIELD, IT DOESNT WORK
const responseData = await admin.graphql(
    `#graphql
    query divContent($id: ID!, $namespace: String!, $key: String!) {
      appInstallation(id : $id) {
        apiKey: metafield (namespace : $namespace, key: $key){
          value
        }
      }
    }
    `,
    {variables: {
      id: id,
      namespace : "super_cart_metafields",
      key: 'div'
    }
  }

And if I use the graphql app on shopify, 0 results...
I read the documentation, but it doesn't work...
https://shopify.dev/docs/api/admin-graphql/2023-10/queries/appInstallation#examples-Get_a_metafield_...

Replies 2 (2)

EasifyApps
Shopify Partner
635 19 47

Hi @wil_dev,

To add text fields effortlessly, you can consider utilizing the Easify Product Options app—it's free and eliminates the necessity for metafields and custom coding 🤗.

 

EasifyApps_0-1701661716264.pngEasifyApps_1-1701661737902.png

 

EASIFY - MAKING SHOPIFY SIMPLE & SWEET!
Easify Product Options: Create custom product options 10X faster & easier!
Easify Product Attachments: Effortlessly add downloadable PDF files (or any other format) to Shopify pages!
Try for Free | 24/7 Live Chat Support
wil_dev
Shopify Partner
12 0 2

Hi thank you for your response, but it's not what I search...
I need to see my app metafields that I have created with a graphQl request. I create the metafield, but impossible to see it with a request, my request is ok, anyone had the same problem?