Skip to content

Rule for select vs update args in update mutations#48

Merged
jakearchibald merged 6 commits intomasterfrom
two-arg-updates
Aug 11, 2023
Merged

Rule for select vs update args in update mutations#48
jakearchibald merged 6 commits intomasterfrom
two-arg-updates

Conversation

@jakearchibald
Copy link
Contributor

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'.

@jakearchibald jakearchibald mentioned this pull request Aug 9, 2023
jakearchibald and others added 3 commits August 9, 2023 13:39
- 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.
Copy link

@gmac gmac Aug 9, 2023

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@jakearchibald jakearchibald merged commit 05cb1c1 into master Aug 11, 2023
@jakearchibald jakearchibald deleted the two-arg-updates branch August 11, 2023 14:06
@heka1024 heka1024 mentioned this pull request Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants