Admin API scopes: `read_products`, `read_shipping`, `read_draft_orders`, `read_customers`, `write_draft_orders`, `write_orders`, `read_orders`, `write_metaobjects`, `read_metaobjects`, `write_metaobject_definitions`, `read_metaobject_definitions`
async function initDraftMetafield(graphqlClient: GraphqlClient) {
return await graphqlClient(METAFIELD_DEFINITION_CREATE, {
variables: { definition: DRAFT_METAFIELD_DEFINITION },
});
}
export const METAFIELD_DEFINITION_CREATE = `#graphql
mutation MetafieldDefinitionCreate($definition: MetafieldDefinitionInput!) {
metafieldDefinitionCreate(definition: $definition) {
createdDefinition {
id
name
key
}
userErrors {
field
message
}
}
}`;
export const DRAFT_METAFIELD_DEFINITION: MetafieldDefinitionInput = {
name: "My Metafield",
namespace: "my_namespace",
key: "my_metafield_key",
description: "Description",
ownerType: MetafieldOwnerType.Draftorder,
pin: true,
type: "single_line_text_field",
capabilities: {
adminFilterable: {
enabled: true,
},
smartCollectionCondition: {
enabled: false,
},
uniqueValues: {
enabled: false,
},
},
access: {
customerAccount: MetafieldCustomerAccountAccessInput.Read,
storefront: MetafieldStorefrontAccessInput.PublicRead,
},
};
I get Failed to handle action: GraphqlQueryError: Access denied for metafieldDefinitionCreate field. Required access: API client to have access to the namespace and the resource type associated with the metafield definition.
in the reponse.
It is crazy but it works perfectly fine with ownerType: MetafieldOwnerType.Order
What am I doing wrong?
Just tried to set all the scopes of the app, it still won’t let me create a draft order definition.