DEV Community

aom19
aom19

Posted on

Manage Local State with Apollo V3

Howdy everyone, In this article,I will show how I removed redux from my project and managed state with Apollo Version .

I will try to show u just the difference between *redux vs apollo *, for design check the first post.

For the project with state managed with Redux check my previous post.
link here: https://dev.to/aom19/new-project-3afh

Project Repository: https://github.com/aom19/rentCar/tree/main/apollo-version

Apollo Version 3

Apollo Client is a comprehensive state management library for JavaScript that enables you to manage both local and remote data with GraphQL. Use it to fetch, cache, and modify application data, all while automatically updating your UI.

Project Structure

Project Structure

Frontend

Frontend Structure
1.Setup
Install Apollo

2.Initialize ApolloClient

Initialize ApolloClient

3.Create Mutations and Queries
Mutations Queries

Mutations

4.Import useQuery & useMutation
Import

5.Simplest way to use a Mutation.
use a Mutation
but this type of mutation won't provide immediately changes on the screen , it will just store that car booked.
for this one, I start update the cache directly rewriting this .
Update cache

Top comments (0)