Oh Hello Apollo Client , Goodbye Redux!
Briefly

"After I started using GQL ✨ I didn't use Redux in the GQL project because we were using React Hooks and React Context and it felt repetitive because you can use useReducer and useContext where you can dispatch actions and update state Apollo Client exposes custom hooks ⚓️ like useQuery, useMutation which automatically exposed loading, success and error states so I didn't need to trigger 3 different actions in my redux store i.e. CART_REQUEST, CART_SUCCESS and CART_ERROR. For example, here is a comparison ⚡️"
"What is considered a good state management solution? ✅ My data is normalized (no dupes please 🙏) Specific actions i.e. user logging in / routing should be able to trigger asynchronous requests 💯 We want to transform the data so that our component is not huge and we can write tests!! 🍵 Lastly, visualize the store i.e. we can view our global state and debug easily 🌎"
Apollo Client 3 integrates GraphQL with React hooks and a normalized cache, enabling both remote and local state management without Redux in many cases. Its useQuery and useMutation hooks automatically provide loading, success, and error states, removing the need to dispatch separate request/success/error actions and reducing boilerplate. React Context with useReducer can replicate dispatch/update patterns for local UI state. Redux offers clear global store visualization, time-travel debugging, and selector-driven transformations, but Apollo's cache, built-in hooks, and reduced action surface simplify asynchronous flows, caching, and testing across typical application needs. Teams can therefore consider consolidating fetching and local state into Apollo to streamline development.
Read at Medium
Unable to calculate read time
[
|
]