-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
chore: add docs for skipping an optimistic update via optimisticResponse #11461
chore: add docs for skipping an optimistic update via optimisticResponse #11461
Conversation
|
size-limit report 📦
|
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Had some minor nits on the sentence, but otherwise looks great! Feel free to take/leave what makes sense to you.
@@ -73,6 +73,51 @@ As this example shows, the value of `optimisticResponse` is an object that match | |||
|
|||
5. Apollo Client notifies all affected queries again. The associated components re-render, but if the server's response matches our `optimisticResponse`, this is invisible to the user. | |||
|
|||
## Bailing out of an optimistic update | |||
|
|||
In some cases you may want to skip an optimisitic update. For example, you may want to perform an optimistic update _only_ when certain variables are passed to the mutation. In order to skip an update, you can pass a function to `optimisticResponse` and use the `IGNORE` sentinel object available on the second argument passed to your `optimisticResponse` function to bail out of the optimistic update. |
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.
In some cases you may want to skip an optimisitic update. For example, you may want to perform an optimistic update _only_ when certain variables are passed to the mutation. In order to skip an update, you can pass a function to `optimisticResponse` and use the `IGNORE` sentinel object available on the second argument passed to your `optimisticResponse` function to bail out of the optimistic update. | |
In some cases you may want to skip an optimistic update. For example, you may want to perform an optimistic update _only_ when certain variables are passed to the mutation. In order to skip an update, you can pass a function to `optimisticResponse` and use the `IGNORE` sentinel object available on the second argument passed to your `optimisticResponse` function to bail out of the optimistic update. |
Typo 🙂
In some cases you may want to skip an optimisitic update. For example, you may want to perform an optimistic update _only_ when certain variables are passed to the mutation. In order to skip an update, you can pass a function to `optimisticResponse` and use the `IGNORE` sentinel object available on the second argument passed to your `optimisticResponse` function to bail out of the optimistic update. | |
In some cases you may want to skip an optimisitic update. For example, you may want to perform an optimistic update _only_ when certain variables are passed to the mutation. To skip an update, pass a function to `optimisticResponse` and use the `IGNORE` sentinel object available on the second argument passed to your `optimisticResponse` function to bail out of the optimistic update. |
I think it reads a touch nicer being a bit more direct here
In some cases you may want to skip an optimisitic update. For example, you may want to perform an optimistic update _only_ when certain variables are passed to the mutation. In order to skip an update, you can pass a function to `optimisticResponse` and use the `IGNORE` sentinel object available on the second argument passed to your `optimisticResponse` function to bail out of the optimistic update. | |
In some cases you may want to skip an optimisitic update. For example, you may want to perform an optimistic update _only_ when certain variables are passed to the mutation. In order to skip an update, you can pass a function to the `optimisticResponse` option and return the `IGNORE` sentinel object available to the second argument passed to your `optimisticResponse` function to bail out of the optimistic update. |
I think being a bit more explicit that this function is for the option and that IGNORE
should be returned. Thoughts?
In some cases you may want to skip an optimisitic update. For example, you may want to perform an optimistic update _only_ when certain variables are passed to the mutation. In order to skip an update, you can pass a function to `optimisticResponse` and use the `IGNORE` sentinel object available on the second argument passed to your `optimisticResponse` function to bail out of the optimistic update. | |
In some cases you may want to skip an optimisitic update. For example, you may want to perform an optimistic update _only_ when certain variables are passed to the mutation. In order to skip an update, you can pass a function to `optimisticResponse` and use the `IGNORE` sentinel object available on the second argument to bail out of the optimistic update. |
Since you've already mentioned that you're passing a function to the optimisticResponse
option, no need to repeat it in the 2nd part of the sentence 🙂
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.
Thanks, +1 to all of these! Updated in 83cc833
Adds docs for #11410.
Checklist: