aerogear / offix

GraphQL Offline Client and Server
https://offix.dev
Apache License 2.0
758 stars 45 forks source link

Subscription Delete Update Query #347

Closed kingsleyzissou closed 4 years ago

kingsleyzissou commented 4 years ago

Bug Report

Currently the subscription delete update query. At the moment, the update function expects the subscriptionData to be returned as an object. This is okay, assuming the return type for the GraphQL delete subscription is the full object, but when the return type is only an ID (as is the case with the delete subscription generated by Graphback Runtime), the update query has no effect.

wtrocki commented 4 years ago

This is Graphback bug rather than Offix bug. In offline/conflict land deletes are usually soft and we need access to the version. We have changed that already inside the Graphback but this is still not released yet.

kingsleyzissou commented 4 years ago

@wtrocki Yeah true, but what about if someone doesn't use a Graphback backend and defines the schema to return the ID only, they would have the same error. Obviously we can't account for every edge case, do you suggest that we put in the docs that the subscription schema should be defined so that the delete subscription always returns the full object? Or do we change the subscription update function in Offix?

wtrocki commented 4 years ago

+1 on having this fixed in offix helpers as well, but only as temporary solution

Our cache update helpers will work only with a simple CRUD scenario. Any relationship/wrapping type/single object returned will cause some nasty issues. Apollo provides a flexible ways to do updates but they are hard to use for beginners. That is why we created those helpers that we can use in our sample apps, but also this helpers were main distraction in offix as there are so many cases that are not covered. That is why I think that offix cache updates should be deprecated and instead of providing codebased helpers we should simply generate code for them and allow people to tweak them afte (graphback plugin).

Instead of maintaining something that technically is possible with Apollo with little more effort or any other client itself we can focus on refining conflicts or providing much better cache storage. Deprecating cache helpers will invalidate many issues: https://github.com/aerogear/offix/labels/cache-updates

kingsleyzissou commented 4 years ago

@wtrocki closing the issue. I have tested this with the example app an it seems like it is no longer a problem after the input mapping updates @darahayes made