-
Notifications
You must be signed in to change notification settings - Fork 493
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
schema.parseUnionDef does not panic on invalid syntax #451
Comments
@ssko1 Thank you very much for the unit test! |
Hey, this issue still unowned? Keen to give this a shot. |
Go for it. PRs are welcome. |
Hey @pavelnikolov - only got a chance to look at this now and after a brief look I believe things are working as expected. I'll provide some sort of proof and then we can get this closed ay 💪 Lets go with the example with a simple schema example; union Foo = Bar Qux | Quux
func parseUnionDef(l *common.Lexer) *types.Union {
union := &types.Union{Loc: l.Location(), Name: l.ConsumeIdent()}
union.Directives = common.ParseDirectives(l)
l.ConsumeToken('=')
union.TypeNames = []string{l.ConsumeIdent()}
for l.Peek() == '|' {
l.ConsumeToken('|')
union.TypeNames = append(union.TypeNames, l.ConsumeIdent())
}
return union
} This function will correctly consume
Am I right in concluding we should leave this as is? In fact, it's exactly to spec, as GraphQL is kinda newline/whitespace agnostic (so trying to wait until a new line char is reached or such to enrich error message will not work) |
You can verify this by playing around with the test here for example; graphql-go/internal/schema/schema_test.go Line 582 in 446a2dd
Just append to the union type in the test case |
Overview
I was writing tests for #444 and noticed that
parseUnionDef
fails for a specific use case.Current Behavior
Given the following union definition snippet
And a small test snippet
The test produces an output:
Expected Behavior
parseUnionDef should panic and the test case should pass, but it does not. The syntax in the union definition snippet is invalid.
The text was updated successfully, but these errors were encountered: