I am fairly new to GraphQL and Apollo however I have been utilizing Redux together with React for the final three years. Based mostly on Apollo documentation, they encourage builders to make use of it as the only supply of reality
We wish to have the ability to entry boolean flags and machine API outcomes from
a number of elements in our app, however do not wish to preserve a separate
Redux or MobX retailer. Ideally, we want the Apollo cache to be the
single supply of reality for all knowledge in our shopper software
I am making an attempt to determine the best way to copy with Apollo what Redux would enable me. In my software, I’ve “Tags”, an array of objects with near 15 completely different fields every. They’re used on three completely different sections of my app and every part reveals particular “Tags” in addition to particular fields from the “Tags”. Based mostly on that, the best way I method this with Redux is to fetch the “Tags” from my API, and, within the reducer, I create completely different arrays containing the IDs of the precise “Tags” I would like for every part and I additionally create a Map (id, worth) with the unique knowledge.
My objective is to copy the identical habits however, although they encourage you to handle your native state utilizing Apollo, I am unsure if what I wish to obtain is feasible in a easy means. I have been following this tutorial from the docs and what they primarily do is including or eradicating further fields to the info acquired from the server by extending the question or mutating the cached knowledge with the @shopper directive.
On the identical time, I perceive GraphQL was thought to question the precise knowledge you want as an alternative of the everyday REST request, nevertheless it feels prefer it would not be environment friendly to do three completely different queries on this case with the precise knowledge I would like for every part.
I am unsure if I am lacking one thing or perhaps Apollo is assumed for a “easier native state administration”. Am I following the suitable path or shall I maintain utilizing Redux with one other library that simply permits me to fetch knowledge with no administration layer?