Optimistic option on ApolloClient.readQuery
See original GitHub issuePre 2.0 I believe that client.readQuery
would also return optimistic mutation results. After upgrading to 2.0 most of my optimistic code broke since I use it in tandem with subscriptions. In the subscription (for a new message) I would read the store and check if an optimistic result was there (designated by a negative ID) and not do anything with the subscription if that were the case. Now that doesn’t work anymore. I did some digging and saw that the apollo-cache
package now has an optimistic: boolean
param in the readQuery
function which would solve my issues but it doesn’t seem to be accessible to the apollo-client
package. Is this intentional or just a missing API that needs to be written?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Optimistic mutation results - Apollo GraphQL Docs
To enable this optimistic UI behavior, we provide an optimisticResponse option to the mutate function that we use to execute our mutation.
Read more >Apollo Cache – Angular - GraphQL Code Generator
Then, you can pass in your newly created cache to ApolloClient. ... you can use the Apollo Client class methods readQuery, readFragment, ...
Read more >Optimistic UIs with React, Apollo Client and TypeScript (Part III)
Whenever the mutate function is called, the Apollo Client checks if an optimisticResponse option is provided for the mutation. If so, then the ......
Read more >optimisticResponse vs update in Apollo Client? - Stack Overflow
As per the docs, if you are updating an existing item, say editing a title of a todo item, you only need optimisticResponse...
Read more >Reason Apollo Cache Update Patterns - peterpme
Updating the cache using an optimistic response reduces the amount of… ... ReadQuery(GetAssets); module AssetWriteQuery = ApolloClient.WriteQuery(GetAssets) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
it’s the same as the result of
this.initProxy()
so yes, you’ll need to passtrue
as the second prop to query in the optimistic results toohttps://github.com/apollographql/apollo-client/pull/2429 addresses this and was merged. Thanks!