Closed yamad07 closed 1 year ago
I'm closing this PR as I believe that this issue is not an issue with the library per se but rather an incorrect interpretation of the GraphQL spec. If you can show me that the GraphQL spec allows this, then I'd be happy to re-consider such a PR. This issue can be resolved with input object's field set to a variable, which in turn has a default value. See this example. Thank you!
Fix https://github.com/graph-gophers/graphql-go/issues/429
I have resolved the issue that prevented the inclusion of default values in optional fields. With this change, it's now possible to specify default values for optional fields, and when null is explicitly passed, it is treated as
nil
, not the default value, within the resolver.In order to implement this change, I modified the packer code. I added a conditional branch for when the type passed to unmarshalInput is
reflect.Pointer
, ensuring it is properly unmarshalled. If this kind of conditional branching is inappropriate according to the design intentions of the packer, please leave a comment.Also, I've adjusted the
starwars
schema for testing this logic. If this method of testing is deemed inappropriate, please provide feedback.