Closed ssko1 closed 1 year ago
The panic occurs when resolvable.go
tries to deserialize the directive's nullable argument L652-654
for _, arg := range d.Arguments {
args[arg.Name.Name] = arg.Value.Deserialize(nil)
}
@ssko1 Thank you for reporting this. I'll try to reproduce and fix it.
I would like to contribute to this project @pavelnikolov. May I take this one? What should be the expected behavior?
"There should be no panic" would be the ideal behavior at a high level.
A bit underneath the hood, it seems that resolvable.go#L567-569
should be checking for directive arguments that were not passed (recall that explicit nulls is different than no argument). The code shouldn't attempt to pack an argument value that does not exist.
The test case that I provided above will show the line that panics.
I haven't had a chance to test and review this, however, at first glance it seems that @ssko1 has given enough information. My wild guess is that we iterate over the argument definition instead of iterating over the passed arguments. The definition will always be a supper-set and some args might be missing (which is exactly what seems to be happening in the failing example).
@EverWinter23 the argument definition list is what you have in your schema - we should not iterate over that. Instead we should iterate over the arguments that are passed in the incoming query and create a packer only for those. I'll probably be able to check this out over the weekend. In the meantime PRs would be welcome.
@pavelnikolov @ssko1 I have raised a PR. Could you please go through it add add your thoughts? I was able to address the issue, however I am unsure about the correctness.
Expected
The following schema parses with
graphql.MustParseSchema()
Actual
graphql.MustParseSchema
panics with a nil pointer dereferenceBasic Test Case