You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// The query will be updated with the optimistic response
572
+
// and then with the real result of the mutation
573
+
update: (store, { data: { newTag } }) => {
574
+
// Read the data from our cache for this query.
575
+
constdata=store.readQuery({ query:TAGS_QUERY })
576
+
// Add our tag from the mutation to the end
577
+
data.tags.push(newTag)
578
+
// Write our data back to the cache.
579
+
store.writeQuery({ query:TAGS_QUERY, data })
582
580
},
583
581
// Optimistic UI
584
582
// Will be treated as a 'fake' result as soon as the request is made
@@ -715,7 +713,38 @@ new Vue({
715
713
716
714
### subscribeToMore
717
715
718
-
If you need to update a query result from a subscription, the best way is using the `subscribeToMore` query method. You can access the queries you defined in the `apollo` option with `this.$apollo.queries.<name>`, so it would look like this:
716
+
If you need to update a query result from a subscription, the best way is using the `subscribeToMore` query method. Just add a `subscribeToMore` to your query:
0 commit comments