FG
๐Ÿ’ป Software๐Ÿ”Œ APIs & SDKs

Less strict validation of input objects

Freshover 7 years ago
Mar 14, 20260 views
Confidence Score78%
78%

Problem

I'm wondering if we really need raise an error wen additional field is passed as part of an input object. see: https://github.com/graphql/graphql-js/blob/master/src/utilities/isValidJSValue.js#L67-L72 Any additional fields could just be ignored or dropped and warnings rather than errors produced.

Error Output

error wen additional field is passed as part of an input object.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
74% confidence100% success rate6 verificationsLast verified Mar 14, 2026

Solution: Less strict validation of input objects

Low Risk

@leebyron Sorry I think you misunderstood my suggestion. I'll try and explain in more detail. This error is raised when type checking the contents of a var with input schema types, for example if the following schema is created: [code block] with this query: `query ($coords: CoordsInput) { field(coords: $coords) }` and the input variable: [code block] Then that results in an Unknown field err

74

Trust Score

6 verifications

100% success
  1. 1

    @leebyron Sorry I think you misunderstood my suggestion. I'll try and explain in

    @leebyron Sorry I think you misunderstood my suggestion. I'll try and explain in more detail. This error is raised when type checking the contents of a var with input schema types, for example if the following schema is created:

    text
    with this query: `query ($coords: CoordsInput) { field(coords: $coords) }`
    
    and the input variable:
    
    ```
    {
      "coords": {
        "lat": 37.5,
        "long": -122.4,
        "alt": 105.7
      }
    }
  2. 2

    with this query: `query ($coords: CoordsInput) { field(coords: $coords) }`

    with this query: `query ($coords: CoordsInput) { field(coords: $coords) }`

  3. 3

    Then that results in an Unknown field error since `alt` is not in the schema. I

    Then that results in an Unknown field error since `alt` is not in the schema. I believe that we shouldn't throw an error here, or at least have some kind of flag which suppresses this error.

  4. 4

    The reason I highlight this issue is that I think it's a case the robustness pri

    The reason I highlight this issue is that I think it's a case the robustness principle:

Validation

Resolved in graphql/graphql-js GitHub issue #303. Community reactions: 21 upvotes.

Verification Summary

Worked: 6
Partial: 2
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

graphqlapischema