# Shopify Function - validationCreate mutation Query issues

**URL:** <https://community.shopify.com/t/shopify-function-validationcreate-mutation-query-issues/365531>\
**Category:** Functions\
**Tags:** input-queries, troubleshooting\
**Created:** [October 11, 2024, 8:47am UTC](https://community.shopify.com/t/shopify-function-validationcreate-mutation-query-issues/365531 "2024-10-11T08:47:38Z")\
**Posts on this page:** 1\
**Page:** 1

## AI-generated 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.

<div class="post-metadata">

**Author:** ![JohnDoe3](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@JohnDoe3](https://community.shopify.com/u/JohnDoe3)\
**Post date:** [October 11, 2024, 8:47am UTC](https://community.shopify.com/t/shopify-function-validationcreate-mutation-query-issues/365531/1 "2024-10-11T08:47:38Z")

</div>

What is wrong with this query and variables?

- References document: [https://shopify.dev/docs/api/admin-graphql/2024-10/mutations/validationCreate](https://shopify.dev/docs/api/admin-graphql/2024-10/mutations/validationCreate)

- Query and variables:

```ruby
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:

```javascript
{
  "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:

```ruby
{
  "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"
      }
    }
  ]
}

```
