-
Notifications
You must be signed in to change notification settings - Fork 211
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
nullable openapi properties converted to non-nullable gql fields #359
Comments
Very interesting! I will review the spec but thank you so much for reporting this issue! This is an important distinction. |
Thinking about this a bit more I don't think that To be useful during mutation, GQL would need to be able to validate the presence of a field independently of it's type. GQL can't do that though- every non-nullable field of an input type is implicitly also required. If For |
After some more careful review, I believe you are correct! This bug originally stems from a misunderstanding of what |
Any progress on this? |
Setting |
OpenAPI properties may be
nullable
&required
.required
only indicates that a key must be present in an object to be valid, it makes no restriction on the type of the value corresponding to that key.openapi-to-graphql
assumes thatrequired
OpenAPI properties are non-nullable:openapi-to-graphql/packages/openapi-to-graphql/src/schema_builder.ts
Lines 622 to 623 in a06d6f4
To Reproduce
Use
openapi-to-graphql
on a spec with type with a required field that is also nullable. Queries for that type which return a null for that nullable field cause unexpected validation errors.Expected behavior
No validation errors when returning nulls for explicitly nullable fields.
The text was updated successfully, but these errors were encountered: