Open
Description
Consider this query, which uses a variable in a directive that is itself applied to a variable definition:
query ($v:Int @dir(arg:$v)) { __typename }
The spec's grammar for VariableDefinition implies that directives applied to variable definitions are constant and that this usage is invalid.
This pattern is not rejected by the graphql-java validator when it should be. For comparison, graphql-js rejects this query:
import { buildSchema, parse, validate } from 'graphql';
const schemaString = `
directive @dir(arg:Int) on VARIABLE_DEFINITION | FIELD
type Query { x: Int }
`;
const documentString = `query ($v:Int @dir(arg:$v)) { x @dir(arg:$v) }`;
const errors = validate(buildSchema(schemaString), parse(documentString));
errors.forEach((err) => console.log(`${err.message}`));
// running the above script throws this error:
GraphQLError: Syntax Error: Unexpected variable "$v" in constant value.
Metadata
Metadata
Assignees
Labels
No labels