-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add required variable validation #100
Comments
I'm going to leave this blocked on the new parser for now, which should fix a few validation issues. |
Sorry I missed the discussion on the new parser, you mean on https://github.com/graph-gophers/graphql-go? Is there something I can help with? |
The parser we are currently using was copied out of the graph-gophers repo because we cant use internal pacakges across repos. It has fallen behind the spec so it needs some work, and the internal package is hurting collaboration. One of the big blockers is that the scanner is built on go's @tonyghita has made a start on writing a new tokenizer, I'm hoping we can spin it out into a separate repo, maybe under the gophers-graphql org and iterate there without breaking anything until it looks good enough to integrate. @seeruk is also working on a request parser over in https://github.com/bucketd/go-graphqlparser which looks very fast, but doesn't do any schema parsing. The validation library sits next to the parser https://github.com/graph-gophers/graphql-go/tree/master/internal/validation. Maybe it makes sense to pull some of that over too, if you have the parsed schema and the parsed request you should have all you need to validate the request. There might still be some merit in exploring and benchmarking the various scanner generators, a grammar (bnf, g4, etc) might be easier to keep up to date with the spec and if the generator is any good, should be pretty quick. Its still early days, but if your interested I'll ping you wherever the code ends up. The more 👀 the better. |
Cool, thanks for the summary, I'm definitely interested in contributing to this project 👍 |
Using g4 / antlr would be a smart move |
I thought so too, but the go generator is pretty bad, and the benchmarks are not great:
|
You can probably expect it to get better over time though, and how big are schemas anyway? Surely we're talking milliseconds in parsing right? |
Oh sure, schema parse time is irrelevant it's done offline. The same scanner is probably shared between both the schema and request parser though. They have the same identifier format, types, string parsing, directives, arg syntax, etc. |
My friend and I are still planning on getting schema parsing working with the existing lexer / parser. I believe the lexer should already be outputting the correct tokens for schemas (not actually tried it yet though!) For us, it's always been about how this will perform in the context of an HTTP request. We wanted our parser to have the smallest impact possible, and to at least beat the Node.js version in performance. We saw that surprisingly, the reference implementation on a single core was faster than many other implementations (not only in Go, but also for example in Scala). Personally, I'm extremely excited to see where we can take this. |
I've started working on https://github.com/vektah/graphql-parser, the lexer is 100% compatible with graphql-js's token stream & errors (its passing their test suite)
Perf is good, the 3 allocs are from the whitespace processing in block strings. There could be a hot path for single line blockquotes but thats probably not the common case, so its probably a sane perf/maintainability tradeoff. Lets take further parser related talk over there. |
Fixed in 0.4.0 |
Expected Behaviour
When using variables for query or mutation arguments:
null
.Actual Behavior
No error is returned.
Minimal graphql.schema and models to reproduce
Using the starwars example, execute the following query and do not specify the
id
variable:Expected behavior shown on different external playground example: https://graphqlbin.com/nZ4vTx
(message is
Variable '$id' expected value of type 'ID!' but value is undefined. Reason: Expected non-null value, found null.
)The text was updated successfully, but these errors were encountered: