Closed mjy9088 closed 2 weeks ago
Why do you want to declare the object type field to be non nullable and then overwrite it to make it nullable?
The internals work in a way that the field resolver info is ignored if the field is defined in object type class. Only if there's no such field declared, it will use the field resolver info to register a new field.
I'm just now seeing this because it's buried in so many notifications, sorry.
I found this bug by mistake, and while it's not a fix I need, I'm just reporting it because I found it.
If it's not a bug and that's how it's supposed to work, I guess it doesn't matter! Thanks :)
I guess I should add this to the list of errors in #12 - to tell user that you can't overwrite the type of field via field resolver. Thanks for the report!
Describe the Bug
Say we have GraphQL ObjectType
Foo
with field@Field((type) => Boolean) bar: boolean
, and its field resolver@FieldResolver((returns) => Boolean, { nullable: true }) bar(): boolean | null { return null; }
.Then, resulting schema is
type Foo { bar: Boolean! }
, but querying Foo::bar produces an error:Cannot return null for non-nullable field Foo.bar.
To Reproduce
https://github.com/my-trash-bin/240531.git
Expected Behavior
buildSchema
Boolean
instead ofBoolean!
Logs
Environment (please complete the following information):