-
Notifications
You must be signed in to change notification settings - Fork 192
Rule for select vs update args in update mutations #48
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
Conversation
Co-authored-by: Scott Walkinshaw <[email protected]>
- 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the above to the rule.
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'.