1

I'm building a web app that has a bunch of settings a user can change and some lists that are fetched from the server using GraphQL. If a user is logged in I want to store the settings on the database as well as the global state. If a user is not logged in I want to simply store the data globally and not make any calls to the backend.

I'm currently using Redux-Toolkit for my state management but it doesn't cache the results. The list and each of the list-items content can be quite large so caching is definitely a good idea. How would I go about doing that? I am thinking of some sort of Middleware that checks whether a user is authenticated and based on that makes calls to the backend or not. But I haven't found the right technology stack for that yet. Apollo Client seems to have a huge bundle size, but it would offer handling both states at once, Redux has no caching, but is popular and easy to use with its Toolkit, urql seems to be on the decline looking at its download statistics, however its smaller and offers much what Apollo Client can do. Is there a way to handle this elegantly?

Tobi
  • 363
  • 5
  • 15
  • Perhaps redux-persist can help with caching? – Linda Paiste Feb 23 '21 at 20:29
  • @LindaPaiste I didn't find a lot of documentation on that. So I guess I'll have to keep on searching. But I appreciate your suggestion :) – Tobi Feb 25 '21 at 20:40
  • Just saw this question and I am also in a similar boat. I haven't implemented redux so I am currently learning toward Apollo Client. My only hesitation at the moment is trying to monitor the size of the Apollo cache because I really don't want too heavy of a cache or global state. Ill be doing more digging in the next few weeks and will share anything I find. – Avery-Dante Hinds Sep 22 '22 at 22:09
  • I went with Redux Toolkit and RTK Query. It was a good decision but I think its still not perfect – Tobi Sep 24 '22 at 11:35

0 Answers0