Product Metafields don't update with GraphiQL

Solved
Greg_Kujawa
Shopify Partner
1016 83 229

So if you go into the Shopify web admin for this shop and go into your logged-in user account. See what permissions are listed there. If you are using the Shopify GraphiQL app then the permissions flow from the logged-in user. 

0 Likes
bzbzh
New Member
5 0 0

It's the main root account.

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 229

Mind providing a full screen shot of the GraphiQL app query that's failing? 

0 Likes
bzbzh
New Member
5 0 0

Capture d’écran 2020-11-28 à 2.10.00 PM.jpg

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 229

I just ran this for a ProductVariantUpdate using the GraphiQL app in my test store. It worked fine. See below. I didn't have an exiting product with a defined metafield so it was against a variant child, but seemed to go okay. And you've verified that this particular Shopify account has the appropriate permissions? I know you said that it's the root account, but double-checking might not hurt!

 

Untitled.jpg 

0 Likes
bzbzh
New Member
5 0 0

Well, you were right! Thx for insisting.

I wasn't able to review full rights of the application (or at least they were misleading) but eventually I reinstalled it and it worked.

Side note: it seems to me that the example here: https://shopify.dev/tutorials/manage-metafields-with-graphql-admin-api#updating-the-owning-resource

Lack with the field

"id": "gid://shopify/Metafield/XXX",         

 

Otherwise you get a:  "message": "Key must be unique within this namespace on this resource"

0 Likes
tomasdelaveau
New Member
8 0 0

hey mate, I'm sending this mutation:

mutation {
  productUpdate(input: {
    id: "gid://shopify/Product/6653113303204",
    title: "zinc test",
    metafields: [
      {
        namespace: "global",
        key: "title_tag",
        value: "zinc test",
        valueType: STRING
      }
    ]
  }) {
    product {
      id
      metafields(first: 10, after: null) {
        edges {
          node {
            key
            namespace
            value
          }
        }
      }
    }
    userErrors {
      field
      message
    }
  }
}

and getting this response:

{
  "data": {
    "productUpdate": {
      "product": {
        "id": "gid:\/\/shopify\/Product\/6653113303204",
        "metafields": {
          "edges": []
        }
      },
      "userErrors": []
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 22,
      "actualQueryCost": 12,
      "throttleStatus": {
        "maximumAvailable": 1000.0,
        "currentlyAvailable": 988,
        "restoreRate": 50.0
      }
    }
  }
}

 I'm trying to create the metafield

0 Likes
Iipa
New Member
1 0 0

Hi @tomasdelaveau 

In your query, metafield valueType is not in quotes. It should be "STRING" instead of STRING.

Could that help?

0 Likes