Find App.Metafiled ID

Solved

Find App.Metafiled ID

lokki54
Shopify Partner
55 0 15

How to find the ID of the App.Metafiled?

I am looking on how to delete app.metafield but this require the ID.

The mutation which suppose to allow find id does not have support for OwnerType APP

{ 
          metafieldDefinitions(first:2, ownerType: APP) {
          edges {
            node {
              id,
              key,
              namespace
            }
          }
          }  
        }

 

Argument 'ownerType' on Field 'metafieldDefinitions' has an invalid value (APP)
Accepted Solution (1)

danloomer
Shopify Staff
11 5 4

This is an accepted solution.

Hi @lokki54 

 

You're looking for the ID of a metafield correct? The query you're trying would give you the ID for a metafield definition rather than a metafield, and the APP owner type does not currently support metafield definitions so that's why you're getting that error.

 

You have a couple chances to grab the metafield GID depending on whether need to get it from a newly created metafield or one that's already existing.

 

To grab a newly created one then you can just query on the response of the mutation that creates it:

mutation {
metafieldsSet(metafields: [{namespace: "custom", key: "test", type: "json", value: "[]"}]) {
metafields {
id
namespace
key
}
}
}

 

 

If you've already created this metafield then you can query it by namespace/key and fetch the ID as well:

query {
product(id: "gid://shopify/Product/12312") {
metafield(namespace: "custom", key: "test") {
id
}
}
}

 

 

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 2 (2)

danloomer
Shopify Staff
11 5 4

This is an accepted solution.

Hi @lokki54 

 

You're looking for the ID of a metafield correct? The query you're trying would give you the ID for a metafield definition rather than a metafield, and the APP owner type does not currently support metafield definitions so that's why you're getting that error.

 

You have a couple chances to grab the metafield GID depending on whether need to get it from a newly created metafield or one that's already existing.

 

To grab a newly created one then you can just query on the response of the mutation that creates it:

mutation {
metafieldsSet(metafields: [{namespace: "custom", key: "test", type: "json", value: "[]"}]) {
metafields {
id
namespace
key
}
}
}

 

 

If you've already created this metafield then you can query it by namespace/key and fetch the ID as well:

query {
product(id: "gid://shopify/Product/12312") {
metafield(namespace: "custom", key: "test") {
id
}
}
}

 

 

To learn more visit the Shopify Help Center or the Community Blog.

lokki54
Shopify Partner
55 0 15

Thank you, Danloomer