A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hi,
I am trying to develop my first app and tried to create a metafield following the example linked here.
This is for an app made using $ shopify app create node.
I am new to using graphQL as well. The following error occurred:
GraphQL error: MetafieldDefinitionInput isn't a defined input type (on $definition)
GraphQL error: Field 'metafieldDefinitionCreate' doesn't exist on type 'Mutation'
GraphQL error: Variable $definition is declared by metafieldDefinitionCreate but not used
Code:
const ADD_FIELDS = gql`
mutation metafieldDefinitionCreate($definition: MetafieldDefinitionInput!) {
metafieldDefinitionCreate(definition: $definition) {
createdDefinition {
id
}
userErrors {
field
message
}
}
}
`;
const [addFields, { data, loading, error }] = useMutation(ADD_FIELDS, {
'variables': {
"definition": {
"description": "",
"key": "",
"name": "",
"namespace": "",
"ownerType": "",
"pin": "",
"type": "",
"validations": {
"name": "",
"value": ""
}
}
}
});
Any help is appreciated 🙂 thanks!