3 ms·
I've been using graphql on the FE and BE for about 2 years now, and used REST for about 10 years before that. I really like the apollo client when using React,
by ishjoh 4y ago
I've been using graphql on the FE and BE for about 2 years now, and used REST for about 10 years before that. I really like the apollo client when using React, it's a great fit and let's me avoid the mental complexity of data stores like Redux etc.
On the BE it's not great, harder to reason about than REST and harder to manage. It's also harder to monitor than traditional REST, since REST makes use of a full range of http header codes (the graphql server we used only used http header 200 by default, we have modified this).
What I recently learned is that the apollo client has support for REST APIs, this is a path that seems interesting to me. We've also been looking at FE libraries for REST that have similar interfaces to the apollo client, if you have suggestions please let me know.
- soulchild77 4y agoWe're happy users of react-query[1]. Its stale-while-revalidate approach makes Redux and Co. unneccessary for most use-cases. If you have an OpenAPI spec of your REST API you can auto-generate a react-query based frontend client with Orval[2]. Works pretty well, but probably takes a bit more time to set up. [1] https://tanstack.com/query/v4/ https://tanstack.com/query/v4/ [2] https://orval.dev/ https://orval.dev/
- ishjoh 4y agoThank you, react-query is one of the solutions we were looking into, glad to hear there are happy users of it. One thing I like about the apollo client is that it handles a lot of the cache invalidation for you, where as react-query it seems to be a bit more of a manual process, how are you and your team handling cache invalidation?
- soulchild77 4y agoreact-query indeed doesn't automatically take care of this. We manually invalidate its caches (based on the query key, so you only ever invalidate what has changed) after a mutation happens. It's not as bad as it sounds because most of the time it's just one line of code.