Shopify Function - validationCreate mutation Query issues

Topic summary

A developer is encountering GraphQL errors when attempting to use the validationCreate mutation for Shopify Functions.

The Query Structure:

  • Mutation attempts to create a validation with fields: title, blockOnFailure, enable, functionId, and metafields
  • Variables include configuration data with namespace, key, type, and JSON value for function settings

Errors Encountered:

  1. Field ‘enable’ doesn’t exist on type ‘Validation’ - The enable field is not recognized in the Validation type
  2. Field ‘functionId’ doesn’t exist on type ‘Validation’ - Similar issue with functionId field
  3. Field ‘metafields’ selection mismatch - The metafields field returns MetafieldConnection but has no selections (needs subfields like { edges { node { ... } } })

Current Status:
The discussion remains open with no responses yet. The developer has referenced the official Shopify documentation but the query structure appears to have type mismatches with the actual GraphQL schema.

Summarized with AI on November 5. AI used: claude-sonnet-4-5-20250929.

What is wrong with this query and variables?

query = <<~QUERY
      mutation validationCreate($validation: ValidationCreateInput!) {
        validationCreate(validation: $validation) {
          validation {
            blockOnFailure
            enable
            functionId
            metafields
            title
          }
          userErrors {
            field
            message
          }
        }
      }
    QUERY

    variables = {
      "validation": {
        "title": params["title"],
        "blockOnFailure": true,
        "enable": true,
        "functionId": params["functionId"],
        "metafields": metafield,
      }
    }
  • Variables data:
{
  "validation": {
    "title": "Test",
    "blockOnFailure": true,
    "enable": true,
    "functionId": "5aa7768b-a272-4c2e-b8d3-b734669b4903",
    "metafields": {
      "namespace": "$app:limited_quantity",
      "key": "function-configuration",
      "type": "json",
      "value": "{\"allOrAnyCriteria\":\":all\",\"selectCustomersBy\":{\"name\":\"none\",\"inputs\":[]},\"selectCartBy\":{\"name\":\"none\",\"inputs\":[] },\"itemsToLimitSelector\":{\"name\":\"none\",\"inputs\":[]},\"limitBy\":\":product\",\"maximumAmount\":\"123\"}"
    }
  }
}
  • Errors:
{
  "errors": [
    {
      "message": "Field 'enable' doesn't exist on type 'Validation'",
      "locations": [
        {
          "line": 5,
          "column": 7
        }
      ],
      "path": [
        "mutation validationCreate",
        "validationCreate",
        "validation",
        "enable"
      ],
      "extensions": {
        "code": "undefinedField",
        "typeName": "Validation",
        "fieldName": "enable"
      }
    },
    {
      "message": "Field 'functionId' doesn't exist on type 'Validation'",
      "locations": [
        {
          "line": 6,
          "column": 7
        }
      ],
      "path": [
        "mutationvalidationCreate",
        "validationCreate",
        "validation",
        "functionId"
      ],
      "extensions": {
        "code": "undefinedField",
        "typeName": "Validation",
        "fieldName": "functionId"
      }
    },
    {
      "message": "Field must have selections (field 'metafields' returns MetafieldConnection but has no selections. Did you mean 'metafields { ... }'?)",
      "locations": [
        {
          "line": 7,
          "column": 7
        }
      ],
      "path": [
        "mutation validationCreate",
        "validationCreate",
        "validation",
        "metafields"
      ],
      "extensions": {
        "code": "selectionMismatch",
        "nodeName": "field 'metafields'",
        "typeName": "MetafieldConnection"
      }
    }
  ]
}