VulcanJS / vulcan-npm

The full-stack JavaScript App Framework
https://vulcan-docs.vercel.app
MIT License
31 stars 8 forks source link

Access Apollo client in update function => watched queries won't be updated #7

Open eric-burel opened 4 years ago

eric-burel commented 4 years ago

In Vulcan, commit "3ac1a60b62fb78fd1d71d72f00b11172f34a0ed4" replaced cache by client in Apollo multi query updater. For the record, this function updates list when you create a new item locally. As a default, Apollo only provides you the cache. That's enough in most case, but updating the cache WON'T update watched queries. In this case, you have to call writeQuery on the client object and not just the cache

Our current implementation of Apollo client, and the method to access it, relies on @vulcan/next-apollo, which is a Next specific package (see #6), but we don't want @vulcan/react-hooks to depend on it.

The problem is that Apollo doesn't really provide a way to access the default Apollo client either, and does not include it in the update call parameter. Technically, since you are in the mutation, there is such a client, it is just not exposed in the API.

To be fully solved, this issue must be solved at Apollo client level. Another solution is that the cache should actually trigger watched queries too?

Possibly related: