-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Make some standard fields non nullable #105
Comments
IIRC |
I think (also from the diff) that @ahey was referring to the fact that the Result type as a whole is non-nullable (as you said you always either have a
should instead be
This (as mentioned above) is particularly useful when integrating with TypeScript where nullability is important for type generation. Another doubt I have is: should the input also be non-nullable? |
Ah, yes you are right, we can definitely make that return type non nullable. Going from nullable -> not nullable on a returned type isn't breaking, so I'd definitely accept a PR on that front. As for non-nullable input, that one is more tricky. Not all actions require some kind of input, and if all keys are not required, the input could also be not required. It would be a breaking change to require it, even if we only did it in cases where there was at least one required input inside of it, because nullable -> not nullable on an input type is theoretically breaking. Although in those scenarios the action would fail 100% of the time... 🤷 so maybe fine to just make both changes. overall result type not nullable, and input not nullable only if at least one member is not nullable. |
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.
Last point left from the discussion on ash-project#105
Last point left from the discussion on ash-project#105
* 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
Last point left from the discussion on #105
I just updated and stumbled upon this because my test now failed with At least I think if there is no error there should always be a record returned, otherwise there will be a |
@barnabasJ does this solve the issue? #110 |
#110 introduced the change and #114 reverted it back to the old behaviour for me |
Hey @rbino thanks for rolling with this one! Is it safe to say that this is complete? If so I will close the issue. |
I found another area for improvement, which from my testing appears to be backwards compatible. I have made a PR with the changes in make mutation result errors list non-nullable. Can anyone forsee any issues with this? My understanding is that moving from a nullable list of errors to a non-nullable list of errors is safe, since we always return an empty array in case of no errors. |
Generating a graphql layer for my front-end in typescript, I noticed some fields are unnecessarily nullable. To achieve a more pleasant typescript experience, I propose the following fields be made
non null
:errors
as returned by a mutation. In case of no errors, an empty list will be returned. Furthermore, each item in the error list can also be made not null, since it either exists in the list or not, and we don't want nulls in the list.error.fields
In addition to these fields, I would also like to see the the
_result
fields be made non nullable, as they will always contain theresult
anderrors
fields, except in the case ofroot_level_errors?
being enabled, in which case i suppose the_result
field should be nullable.See here for an example of the changes (not ready for merge, just for discussion)
This would be a breaking change to the existing api. We could keep the existing behaviour as default, and add a config setting to enable the new behaviour. The existing behaviour should be considered deprecated and we could warn to use the flag, and default to use it in v1.0.0.
What do you think?
The text was updated successfully, but these errors were encountered: