Skip to content

Query variables are not validated #292

@wiktor256

Description

@wiktor256

There seems to be a bug in schema validation of query variables.
For this schema:

input SearchFilter {
  required: String!
  optional: String
}

type SearchResults {
  match: String
}

type Query {
  search(filter: SearchFilter!): [SearchResults!]!
}

the following query correctly fails schema validation:

 query  {
   search(filter: {}) {
     match
   }
} 

with the error message:

{
  "errors": [
    {
      "message": "Argument \"filter\" has invalid value {}.\nIn field \"required\": Expected \"String!\", found null.",
      "locations": [
        {
          "line": 2,
          "column": 17
        }
      ]
    }
  ]
}

but the same query using variables doesn't fail at all:

query s($filter:SearchFilter!) {
  search(filter: $filter){
    match
  }
}

variables:
{
  "filter": {}
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions