-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
First round of improvements around non-nullability #110
Conversation
Adjust rool level error tests: since result is now non-nullable, if the content of the result is nil, the whole result becomes nil. Note that this is not a breaking change since GraphQL always allows a field nullability to propagate upwards in case of a field error (see October 2021 spec, section 6.4.4).
For the ids in updates being non nullable, that would be a breaking change for any queries people have, right? I think we'll have to put that behind a configuration for now, and undo it when we do 1.0 for this library. |
Wouldn't the same thing that was discussed in #105 regarding making the input non-nullable apply (see below)?
Anyway, adding a config works for me too, but which kind of config (i.e. at what level) should it be? |
Yeah, but the changes you made in the test made me realize that it's not enough that it wouldn't have worked, because it will break people's type declarations. i.e if they have |
8932ba2
to
67dd52d
Compare
@zachdaniel I've left only the non-breaking result change in this PR and I'll do a separate one with IDs and input objects behind an application config |
As discussed in ash-project#105 and ash-project#110, put this behind an opt-in configuration to avoid breaking existing code. The ID in update mutations is always non-null if non-null mutation arguments are allowed, while input is non-null if it's allowed _and_ there is at least a non-null field in the input. Document the newly added config variable in the getting started guide.
* improvement: make mutation arguments non-null As discussed in #105 and #110, put this behind an opt-in configuration to avoid breaking existing code. The ID in update mutations is always non-null if non-null mutation arguments are allowed, while input is non-null if it's allowed _and_ there is at least a non-null field in the input. Document the newly added config variable in the getting started guide. * chore: enable non-null mutation arguments in tests
Building upon ash-project#110, this restores the old behaviour of the result being nullable when root level errors are present. While the result is guaranteed to not be nullable in standard conditions (since either result or errors are always present), when errors are moved to the root level it could become null, so declaring it non-nullable propagates the null up to the data field. This actually causes compatibility problems with some client libraries (e.g. Relay) that expect the inner result to be null, _not_ data, if there's an error. This also adds dedicated RootLevelErrors versions of the Api and the Schema since the configuration is accessed at compile time now, so put_env was not enough to test them correctly.
Building upon ash-project#110, this restores the old behaviour of the result being nullable when root level errors are present. While the result is guaranteed to not be nullable in standard conditions (since either result or errors are always present), when errors are moved to the root level it could become null, so declaring it non-nullable propagates the null up to the data field. This actually causes compatibility problems with some client libraries (e.g. Relay) that expect the inner result to be null, _not_ data, if there's an error. This also adds dedicated RootLevelErrors versions of the Api and the Schema since the configuration is accessed at compile time now, so put_env was not enough to test them correctly.
Building upon #110, this restores the old behaviour of the result being nullable when root level errors are present. While the result is guaranteed to not be nullable in standard conditions (since either result or errors are always present), when errors are moved to the root level it could become null, so declaring it non-nullable propagates the null up to the data field. This actually causes compatibility problems with some client libraries (e.g. Relay) that expect the inner result to be null, _not_ data, if there's an error. This also adds dedicated RootLevelErrors versions of the Api and the Schema since the configuration is accessed at compile time now, so put_env was not enough to test them correctly.
First round of implementation of what was discussed in #105
This PR makes result types non-nullable.