Error during metafield force-creation using GraphQL API

Topic summary

Error when using Shopify Admin GraphQL to create a metafield definition with forceCreate in MetafieldDefinitionInput; the API rejects the field as undefined.

  • Context: Using metafieldDefinitionCreate with variables including forceCreate: true causes the error. Client: @shopify/shopify-api v5.0.0 (assumed API 2022-10). Code snippets show the mutation and input payload.

  • Shopify response: In API version 2022-10, MetafieldDefinitionInput does not include forceCreate. They requested the exact API version and full variables to investigate further.

  • Update: Another developer on API 2023-07 reports forceCreate is still unavailable and asks for any workaround to create a Metafield Definition from existing metafields.

  • Key question: Is there an alternative method/workaround to “force-create” or derive a Metafield Definition from existing metafields?

  • Outcome/status: No official workaround or solution provided in the thread; issue remains open pending guidance on supported approach without forceCreate.

Summarized with AI on January 23. AI used: gpt-5.

Hi,

I am facing the an issue while force-creating an metafield definition. I have following error message:

“message”: “Variable $definition of type MetafieldDefinitionInput! was provided invalid value for forceCreate (Field is not defined on MetafieldDefinitionInput)”

Can anyone please help me with it?

1 Like

Hi @sratna :waving_hand:

It looks like you’re using the metafieldDefinitionCreate mutation and running into issue with building the variable inputs. The MetafieldDefinitionInput fields doesn’t have a forceCreate field in version 2022-10. Would you kindly share the version you’re using and the full variables payload so that we can take a closer look? Please be sure to redact any private information!

Hi,

Thanks for the reply.

Here is my mutation:

  mutation CreateMetafieldDefinition($definition: MetafieldDefinitionInput!) {
    metafieldDefinitionCreate(definition: $definition) {
      createdDefinition {
        name
      }
      userErrors {
        field
        message
        code
      }
    }
  }

And the variables:

definition: {
            "name": "ID",
            "namespace": "test",
            "key": "id",
            "description": "ID",
            "type": "single_line_text_field",
            "ownerType": "PRODUCT",
            "forceCreate": true,
}

Not sure which shopify-admin-graphql version I am using. I am using graphql client from ` @Shopify_77 /shopify-api -

5.0.0`, so I guess its using the latest version (2022-10).

So, like you said forceCreate is not there in MetafieldDefinitionInput, so is there an alternative way to forceCreate a metafield definition?

Hi @ShopifyDevSup currently we’re on version 2023-07 and looks like the forceCreate field still not available on the API.

Do you know if there is any other workaround to create a Metafield Definition from existing Metafields?