apollo icon indicating copy to clipboard operation
apollo copied to clipboard

Documentation for subscribetomore invalid now.

Open LiamKarlMitchell opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe. The documentation on v4 for subscriptions updateQuery is wrong. https://v4.apollo.vuejs.org/guide-composable/subscription.html#subscribetomore

v3 apollo client made cache read-only / immutable. Uncaught TypeError: Cannot assign to read only property 'propNameHere' of object '#<Object>' https://github.com/apollographql/apollo-client/issues/5903

The cache is read only.

Describe the solution you'd like Documentation example updated so we can use subscribeMore correctly to update the previous query.

Describe alternatives you've considered Copying keys manually to a new object.

Additional context It could be possible that the Subscription type does not seem to match exactly the Query type. So some way to transform it is needed.

LiamKarlMitchell avatar Aug 06 '22 07:08 LiamKarlMitchell

This appears to work (If same shape).

updateQuery: (previousResult, { subscriptionData }) => {
    return {...previousResult, thing: subscriptionData.data.thingUpdated} as ThingQuery;
}

LiamKarlMitchell avatar Aug 06 '22 07:08 LiamKarlMitchell