In my query, I use a blend of remote and local properties. The local properties have different values depending on:
- The remote properties
- The current unix timestamp
The local resolvers computes the local state according to these rules. Now, I face a scenario whereby I need to forego useQuery
and use Apollo Client's query
for enhanced flexibility.
Other than structural differences (e.g. useQuery
accepts two parameters, whereas client.query
takes only one parameter - the options objects), is it safe to use one over the other?
I identified at least one difference not described in the docs. When I call client.query
multiple times, the local resolvers are run only once, at the beginning. With useQuery
, the data always gets recomputed and it has different values (as per #2 above).
useQuery
, like theQuery
component and thegraphql
HOC, useswatchQuery
under the hood.query
just runs your query and returns the result, whilewatchQuery
also subscribes to subsequent changes to the cache. – Divulsionclient.query
, when I call it the 2nd time it should reflect the cached modified by the resolvers. I understand whywatchQuery
syncs this correctly, but I don't understand whyclient.query
doesn't run the resolvers, even if I call it on an interval basis. – Leukemiaapollo-client
handle local state internally to give a full answer. Just hoping to nudge you onto the right track. – Divulsion