jotaijs / jotai-apollo

Apollo graphql client integration for jotai :rocket: :ghost:
MIT License
50 stars 4 forks source link

Does `atomsWithQuery` subscribe to apollo store? #9

Closed mohebifar closed 1 year ago

mohebifar commented 1 year ago

I see that atomsWithQuery uses client.query instead of watchQuery. This implies that the atom won't be updated when there's a change in apollo store that would impact the query result (e.g. another query updating the cache with some cache keys in common with this query). Wondering what the rationale is and whether it was intentional.

https://github.com/jotaijs/jotai-apollo/blob/master/src/atomsWithQuery.ts#L37-L40

Aslemammad commented 1 year ago

It was not intentional, I just tried copying other jotaijs libs patterns and came up with this. And what I see, watchQuery seems more reasonable. Thank you for creating the issue, if anyone wants to take this, please go ahead. I'm a bit busy atm.

dsonck92 commented 1 year ago

I hit this bug as well but would like to attempt to add watchQuery to the atomsWithQuery.