Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hello,
I am using the graphql `metafieldDelete` mutation to delete a metafield and the api responds with an error saying metafield id not found. I build the api request to delete by using metafield ids I get from the products graphql api and I can see the metafield with the id exists. We are using api version `2020-07`.
Here is the mutation call:
mutation MetafieldDelete($input: MetafieldDeleteInput!) {
metafieldDelete(input: $input) {
deletedId
userErrors {
field
message
}
}
}
## Variables
{
"input": {
"id":"gid://shopify/Metafield/14348829261981"
}
}
This feels like an internal error, as I am sure about both the api request and the existence of that field and this api used to work in the past.
Anyone have any insights?
Edit: This seems to be an issue with one of our shops, so my first guess was permission issues but the permissions of the apps we use are identical.
Thanks!
Solved! Go to the solution
This is an accepted solution.
Hey @cur8d
Can you confirm which scopes are granted to your app? This is seeming more like a permissions issue based on the errors I am seeing. Can you confirm your app has the "write_products" scope selected?
Kevin_A | Solutions Engineer @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hey @cur8d
I see you are using the Shopify GraphiQL app on your shop. It looks like you never granted the app the correct permissions to make writes. I see it has read permissions, but you will need to remove it and reinstall it with additional write permissions to be able to use a mutation.
Kevin_A | Solutions Engineer @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi @Kevin_A
Thanks for the response. I am trying to do this in the our app code and using a private app account configured on Shopify. As I mentioned in the edit, it works fine in another shop instance that we own. The permissions for this private app is the same on both shops.
Thanks!
Hey @cur8d
Can you grab the x-request-id response header for the call that doesn't work? When I looked yesterday, the only mutation I saw for the metafield with id "gid://shopify/Metafield/14348829261981" was being made from the Shopify GraphiQL app.
Kevin_A | Solutions Engineer @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
I didn't have that product handy, but have the same error with another id.
New metafield id: `gid://shopify/Metafield/14503551631517`
`X-Request-Id: aa17c889-aa74-4dd4-b241-b0bd06c1cb3e`
Here is the response:
{
"data":{
"metafieldDelete":{
"deletedId":null,
"userErrors":[
{
"field":[
"id"
],
"message":"Metafield does not exist"
}
]
}
},
"extensions":{
"cost":{
"requestedQueryCost":10,
"actualQueryCost":10,
"throttleStatus":{
"maximumAvailable":1000,
"currentlyAvailable":990,
"restoreRate":50
}
}
}
}
@cur8d wrote:Hi @Kevin_A
Thanks for the response. I am trying to do this in the our app code and using a private app account configured on Shopify. As I mentioned in the edit, it works fine in another shop instance that we own. The permissions for this private app is the same on both shops.
Thanks!
This is an accepted solution.
Hey @cur8d
Can you confirm which scopes are granted to your app? This is seeming more like a permissions issue based on the errors I am seeing. Can you confirm your app has the "write_products" scope selected?
Kevin_A | Solutions Engineer @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi @Kevin_A ,
The following permissions are granted:
Thanks!
Hey @cur8d
Thanks for confirming. Can you try and reproduce once more for me and provide the metafield ID and request ID. Our logs don't have enough retention for me to see the logs from the last example you sent.
Kevin_A | Solutions Engineer @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi @Kevin_A
Sorry about the late response. This is our bad actually. The service that handled metafield deletion internally was configured to use different app credentials.
Thanks for your help on this!