Adding metafields error

J-dance
Shopify Partner
2 0 1

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!

Replies 0 (0)