You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems there is no validation for the argument types of custom schema directives.
Passing an argument with the wrong type to a custom schema directive doesn't throw an error during schema building, e.g. with buildASTSchema or buildSchema. Meanwhile, built-in schema directives like deprecated seem to validate their argument types correctly.
This results in the arguments of a custom schema directive possibly ending up with an unexpected type and your server breaking at runtime when you figure out the bug in your schema. Notably, the type ends up being EnumValue if it doesn't exist as this seems to be the default type.
Steps to reproduce
Run with deno, e.g. open deno repl and paste in, or run from file with deno run file.ts
import{buildSchema}from"npm:[email protected]";constsource1=` type Query { # ups... forgot the quotes around the string FOOBAR baz: Boolean @foo(bar: FOOBAR) } directive @foo(bar: String!) on FIELD_DEFINITION`;// should throw but doesn'tconstschema1=buildSchema(source1);console.log(schema1.getQueryType()!.getFields()["baz"].astNode!.directives![0].arguments![0].value.kind);// EnumValueconstsource2=` type Query { # ups... forgot the quotes around the string FOOBAR baz: Boolean @deprecated(reason: FOOBAR) }`;// correctly throwsconstschema2=buildSchema(source2);// error: Uncaught GraphQLError: Argument "reason" has invalid value FOOBAR.
Expected result
The buildSchema(source1) call throws like the buildSchema(source2) does.
Actual result
The buildSchema(source1) call doesn't throw.
The text was updated successfully, but these errors were encountered:
It seems there is no validation for the argument types of custom schema directives.
Passing an argument with the wrong type to a custom schema directive doesn't throw an error during schema building, e.g. with
buildASTSchema
orbuildSchema
. Meanwhile, built-in schema directives likedeprecated
seem to validate their argument types correctly.This results in the arguments of a custom schema directive possibly ending up with an unexpected type and your server breaking at runtime when you figure out the bug in your schema. Notably, the type ends up being
EnumValue
if it doesn't exist as this seems to be the default type.Steps to reproduce
deno repl
and paste in, or run from file withdeno run file.ts
Expected result
The
buildSchema(source1)
call throws like thebuildSchema(source2)
does.Actual result
The
buildSchema(source1)
call doesn't throw.The text was updated successfully, but these errors were encountered: