Accessing Apollo GraphQL data globally

As our app keeps growing, I’m starting to have troubles managing that data from within our React client. The key problem is that same data is required from several components. Right now, I am using a simplistic solution and just pass all the data from parent to children as props . However, ideally I’d like to avoid that and use something like Redux-like pattern to have access to all app data globally, and avoid props drilling.

I wonder what your approach has been like in regards to this? Of course, I can always store the fetched data in Redux store (or similar) but perhaps Apollo GraphQL offers something out of the box for this that I’m missing? Especially since it promises to be a replacement for Redux I suspect some kind of convenient way to store app data globally is a must-have.

@karooolis with Apollo Client you have 2 main options for storing state that will live outside of your components:

  1. Store your data in the Apollo Client cache.
  2. Store your data in reactive variables.

We have an example app here that shows different patterns for storing state with AC, including mixing AC with Redux if you prefer that approach.

1 Like