Rule for select vs update args in update mutations#48
Merged
jakearchibald merged 6 commits intomasterfrom Aug 11, 2023
Merged
Conversation
swalkinshaw
reviewed
Aug 9, 2023
Draft
Co-authored-by: Scott Walkinshaw <scott.walkinshaw@gmail.com>
gmac
reviewed
Aug 9, 2023
| - Rule #23: Most payload fields for a mutation should be nullable, unless there is really a value to return in every possible error case. | ||
| - Rule #22: For update mutations, the argument relating to selecting the entry must be separate to the argument providing the change data. | ||
| - Rule #23: Mutations should provide user/business-level errors via a userErrors field on the mutation payload. The top-level query errors entry is reserved for client and server-level errors. | ||
| - Rule #24: Most payload fields for a mutation should be nullable, unless there is really a value to return in every possible error case. |
There was a problem hiding this comment.
It also seems worth pointing out that most condition fields should be not-null, again unless there really is value in making the condition an optional filter. We should never see a nullable primary condition though, ie: collectionUpdate(id: ID, payload: ...) should be id: ID!. Maybe this goes into Rule 22?
Contributor
Author
There was a problem hiding this comment.
How about:
For update mutations, the argument relating to selecting the entry must be separate to the argument providing the change data. The argument to select the entry should be non-nullable unless there's value in making the condition an optional filter.
Contributor
Author
There was a problem hiding this comment.
I've added the above to the rule.
swalkinshaw
approved these changes
Aug 10, 2023
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This effectively deprecates patterns like https://shopify.dev/docs/api/admin-graphql/2023-07/mutations/productUpdate, where the arg is a combination of 'select' and 'update'.