New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Graphiql tries to read string as integer and fails since it starts with 07 #89
Comments
@buma so I've tried to reproduce with example app, and got this:
I was thinking this might be a difference between how |
Interesting. @andimarek any idea if this is graphql-java bug or bug in my code? GraphQLFieldDefinition planField = GraphQLFieldDefinition.newFieldDefinition()
.name("plan")
.description("Gets plan of a route at a specific time")
.type(profileResponseType)
.argument(GraphQLArgument.newArgument().name("from")
.type(new GraphQLNonNull(inputCoordinateType)).build())
.argument(GraphQLArgument.newArgument()
.name("to")
.type(new GraphQLNonNull(inputCoordinateType))
.build())
.argument(GraphQLArgument.newArgument()
.name("fromTime")
.type(Scalars.GraphQLString)
.description("The beginning of the departure window, in HH:MM")
.defaultValue("07:30")
.build())
.argument(GraphQLArgument.newArgument()
.name("toTime")
.type(Scalars.GraphQLString)
.description("The end of the departure window, in HH:MM")
.defaultValue("10:30")
.build())
.build(); |
Thanks for the report! From @asiandrummer's analysis this appears to be a clear bug in graphql-java or at least a shortcoming in the API http://facebook.github.io/graphql/#sec-The-__InputValue-Type This part of the spec describes the default value field as being a string encoded in the graphql language. So we can provide numbers, booleans, and strings with "3", "true", and ""str"", respectively. |
Currently, the onlineParser doesn't alter token state for special tokens like `comment` or `invalidchar`. When you load the token state for one of these tokens, it appears to be whatever came before it. When building "intelisense" features for IDEs this can be a complicating factor. This proposes adding two new special parse rules "Comment" and "Invalid" and altering the parser behavior to detect and insert them when necessary. This also results in onlineParser becoming more generic with respect to Comment lexer rules. Previously onlineParser knew more than it should about how comments are defined. Now, the provided parse rules (specifically the lexer rules) supply the definition for `Comment`. Finally, this removes global state from the parser when saving and resuming backup states, keeping that context contained within the parser function. That removes the possibility for poisoning the parse state.
This builds on graphql#89 and graphql#90 to create a more specific parser rule and parser state for NamedType. This makes it easier to builds tools on top of codemirror-graphql which do interesting things when the names of types are encountered, such as jump-to-docs or hover cards.
Since graphql#89, hint no longer shows typeaheads for invalid token states. This uses the technique found in `variables/hint.js` in `getHintsAtPosition`.
I am using java-graphql and graphiql for testing. I added custom graphql type for time which is represented as string in GraphQL but problem is that GraphiQL fails when parsing introspection query since it seems to try to read defaultValue it as integer and fails. Since I get an error:
It works correctly in "toTime" which has defaultValue 10:00. And it also works correctly if defaultValue is "7:30".
This is part of introspection response:
And link to full response.
The text was updated successfully, but these errors were encountered: