A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello,
I'm trying to use the recently introduced graphql API_PERMISSION ownership type in order to create my app metafields which i can use in theme-extension snippets.
Unfortunately it returns me this error:
{
"data": {
"metafieldDefinitionCreate": {
"createdDefinition": null,
"userErrors": [
{
"field": [
"definition",
"ownerType"
],
"message": "Owner type is not included in the list",
"code": "INCLUSION"
}
]
}
},
"extensions": {
"cost": {
"requestedQueryCost": 10,
"actualQueryCost": 10,
"throttleStatus": {
"maximumAvailable": 1000,
"currentlyAvailable": 990,
"restoreRate": 50
}
}
}
}
I dont understand what does "Owner type is not included in the list" means.
THank you.
Solved! Go to the solution
This is an accepted solution.
Hello,
It seems you are using metafieldDefinitionCreate mutation. Instead, you will need to use metafieldSet mutation from Admin API 2022-04 or above in order to create app-owned metafields.
Here is an example:
mutation metafieldsSet($metafields: [MetafieldsSetInput!]!) { metafieldsSet(metafields: $metafields) { metafields { # Metafield fields } userErrors { field message } } }
Mutation variables could be for example
{ "metafields": { "key": "feature1", "namespace": "sample_app", "ownerId": "<App installation ID>", "type": "boolean", "value": "true" } }
In order to get App Installation Id, you can use the following GraphQL query:
appInstallation { id }
I hope this helps,
Feken
Feken | 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
This is an accepted solution.
Hello,
It seems you are using metafieldDefinitionCreate mutation. Instead, you will need to use metafieldSet mutation from Admin API 2022-04 or above in order to create app-owned metafields.
Here is an example:
mutation metafieldsSet($metafields: [MetafieldsSetInput!]!) { metafieldsSet(metafields: $metafields) { metafields { # Metafield fields } userErrors { field message } } }
Mutation variables could be for example
{ "metafields": { "key": "feature1", "namespace": "sample_app", "ownerId": "<App installation ID>", "type": "boolean", "value": "true" } }
In order to get App Installation Id, you can use the following GraphQL query:
appInstallation { id }
I hope this helps,
Feken
Feken | 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
Thank you Feken for directing me!
Def useful.
Hello, probably its hard to find in their docs, can you share a link pleasE?
I cant find any explanation here: https://shopify.dev/api/admin-rest/2022-07/resources/metafield#post-orders-order-id-metafields
@Feken Thanks for the answer. it was really help out.
now i want to access the app meta field to the theme app extension. here my questions https://community.shopify.com/c/shopify-apis-and-sdks/want-to-access-the-app-meta-field-to-the-theme...