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 appears in the SchemaParser#createInputObject that the default value of input fields is not set to a proper value if it is an enum.
When the default value of a field on an input type is an enum, the parser is supplying an EnumValue, and it is being set, so when the schema metadata is retrieved, a CoercingSerializeException is thrown by graphql-java, since it can't do any comparison of `EnumValue.
However, further down the SchemaParser, the createField method uses the buildDefaultValue function for the default value. By simply changing createInputObject to use buildDefaultValue, this seems to fix it.
The value being passed in ends up looking like EnumValue{name='FOO'}, which will never match, but by using buildDefaultValue, it turns it into the enum name, which the check will succeed.
All of this is may be moot point however, since it appears that graphql-java doesn't seem to support default values inside of input types (it gets coerced into a null value if is not present). However, I believe this is definitely a bug on the graphql-java-tools side.
What I'm not sure of is the possible complications of always using buildDefaultValue(inputDefinition.defaultValue), if any.
The text was updated successfully, but these errors were encountered:
It appears in the
SchemaParser#createInputObject
that the default value of input fields is not set to a proper value if it is an enum.When the default value of a field on an input type is an enum, the parser is supplying an
EnumValue
, and it is being set, so when the schema metadata is retrieved, aCoercingSerializeException
is thrown by graphql-java, since it can't do any comparison of `EnumValue.graphql-java-tools/src/main/kotlin/com/coxautodev/graphql/tools/SchemaParser.kt
Lines 184 to 204 in bdafe57
However, further down the
SchemaParser
, thecreateField
method uses thebuildDefaultValue
function for the default value. By simply changingcreateInputObject
to usebuildDefaultValue
, this seems to fix it.graphql-java-tools/src/main/kotlin/com/coxautodev/graphql/tools/SchemaParser.kt
Lines 283 to 301 in bdafe57
The issue tracks down to the
GraphQLEnumType
:https://github.com/graphql-java/graphql-java/blob/8ba2d1da9a84d4490b59f59a43fb0d2f4d58a0f1/src/main/java/graphql/schema/GraphQLEnumType.java#L138-L162
The value being passed in ends up looking like
EnumValue{name='FOO'}
, which will never match, but by usingbuildDefaultValue
, it turns it into the enum name, which the check will succeed.All of this is may be moot point however, since it appears that
graphql-java
doesn't seem to support default values inside of input types (it gets coerced into a null value if is not present). However, I believe this is definitely a bug on the graphql-java-tools side.What I'm not sure of is the possible complications of always using
buildDefaultValue(inputDefinition.defaultValue)
, if any.The text was updated successfully, but these errors were encountered: