Skip to content

GraphQL validation: "variable not defined" ignored #3393

@aasseman

Description

@aasseman

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Queries with undefined variables are accepted by the graph-node. This is invalid as per the GraphQL spec: https://spec.graphql.org/June2018/#sec-All-Variable-Uses-Defined

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
Example with The Graph subgraph. Same behavior on all subgraphs.
Query:

query {
  allocations(first: $first) {
    id
  }
}

Variables:

{
  "first":  10
}

===> OK

What is the expected behavior?
Query:

query {
  allocations(first: $first) {
    id
  }
}

Variables:

{
  "first":  10
}

===> ERROR
But with

query ($first: Int) {
  allocations(first: $first) {
    id
  }
}

===> OK

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions