In my embedded shopify app, I have an action route where im attempting to make graphql queries using admin.graphql. This works as expected with most of the queries I’ve used so far. However when using metaobjectDefinitionsCreate
:
export const mutationCreateMetaobjectDefinition = `#graphql
mutation CreateMetaobjectDefinition($definition: MetaobjectDefinitionCreateInput!) {
metaobjectDefinitionCreate(definition: $definition) {
metaobjectDefinition {
name
type
fieldDefinitions {
name
key
}
}
userErrors {
field
message
code
}
}
}
`;
let res = await admin.graphql(
mutationCreateMetaobjectDefinition,
{
variables: {
definition: {
name: 'Size Chart',
type: 'size-chart',
fieldDefinitions: [
{
description: 'Metaobject definition for product size charts',
key: 'chart',
name: 'Chart',
type: 'json',
validations: [
{
name: 'schema',
value: JSON.stringify({
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "SizeChartAsArrayOfArrays",
"type": "array",
"items": {
"type": "array",
"items": {
"type": "string"
}
}
})
}
]
}
]
}
}
}
);
I receive the following error:
Error using admin graphQL GraphqlQueryError: Access denied for
metaobjectDefinitionCreate field. Required access: `write_metaobject_definitions` access scope.
My TOML has the required access scope (I have added both the read and write access scopes):
[access_scopes]
# Learn more at https://shopify.dev/docs/apps/tools/cli/configuration#access_scopes
scopes = "read_discounts,write_discounts,write_products,read_products,write_pixels,read_customer_events,read_orders,write_orders,read_metaobject_definitions,write_metaobject_definitions,read_metaobjects,write_metaobjects"
I have verified in the partner dashboard that the TOML access scopes are showing up:
I have uninstalled my app from the dev store and reinstalled it. I have also redeployed the app, and I ran the following graphql query:
let res = await admin.graphql(`#graphql
query Scopes {
shop {
name
}
app {
availableAccessScopes {
description
handle
}
requestedAccessScopes {
description
handle
}
}
}`);
which confirms that the access scopes are there:
requestedAccessScopes: Array (13)
0 {description: "Read browsing behavior", handle: "read_customer_events"}
1 {description: "Read discounts", handle: "read_discounts"}
2 {description: "Read metaobject definitions", handle: "read_metaobject_definitions"}
3 {description: "Read metaobjects", handle: "read_metaobjects"}
4 {description: "Read orders, transactions, and fulfillments", handle: "read_orders"}
5 {description: "Read products, variants, and collections", handle: "read_products"}
6 {description: "Modify discounts", handle: "write_discounts"}
7 {description: "Write metaobject definitions", handle: "write_metaobject_definitions"}
8 {description: "Write metaobjects", handle: "write_metaobjects"}
9 {description: "Modify orders, transactions, and fulfillments", handle: "write_orders"}
10 {description: "Write access for pixels", handle: "write_pixels"}
11 {description: "Modify products, variants, and collections", handle: "write_products"}
12 {description: "Read access for pixels", handle: "read_pixels"}
I have no idea why this isnt working, I have gotten this to work in other applications. Is there a limit to the amount of access scopes any one app can have?
Any help would be greatly appreciated!