What do you guys use/recommend? Was planing on using vue with apollo client but due to some components that I really need only being available in React looks like I don’t have much choice but to go with React. What in your experience works better Relay vs apollo with React apps and what do you use for local state (I only use MobX before)?
I’ve only used apollo in my own projects, but a team I work with uses relay, and i definitely remember a lot of swearing when they were first implementing the client. That was about a year ago so YMMV.
For state I basically lift it into higher level components, and lean on apollo’s cache for anything coming from outside. I find you can get pretty far with that.
I cannot tell for Apollo, but I have tried Relay modern some months ago. At the time it was still beta.
What I can tell is it succeeds in decoupling view from API. In fact, You build your views, it “compiles” queries (this is for Relay modern, it build stored procedures from views to go faster).
Also I could use unlimited pagination, and filter by search. I did not succeed to make them work both together as there was some bugs in the beta, at that time.
It is meant to replace existing store. It is meant to replace Redux.
I choose this over Apollo mainly because it is made to work well with React and React Native.
I’ve come across a number of posts that claim that after the introduction of a GraphQL client (with its cache) people dropped Redux and simply lifted all their remaining state up all the way to the top component (pushing shared state and mutators down via props) - so I guess it depends on how much local application state you actually have in your UI.
Also note that they’ve finally published a Context API that is no longer experimental, so there is officially another way for components to share context apart from props. Whether that is a good idea remains to be seen. While it will certainly cut down on pass-through props, practicing good context hygiene is left up to the developer (e.g. don’t throw everything into one single context - a glorified global).