Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Looking for example with remote data combined with local data #41

Open
Yasir5247 opened this issue Feb 8, 2021 · 0 comments
Open

Looking for example with remote data combined with local data #41

Yasir5247 opened this issue Feb 8, 2021 · 0 comments

Comments

@Yasir5247
Copy link

Yasir5247 commented Feb 8, 2021

A good real world 'use case' would be a shopping cart. below is a typical result object for a shopping cart.
The goal here is to set a local variable called "user_selected_qantity" with the shopping cart remote data. and initialize a default value for it. here user should be able to increment and decrement "user_selected_qantity" for the given product. becuase evertime a user increments qty for the product it should not have to go to the server right. I hope i'm explaining this correctly

{
    "data": [
        {
            "id": 1,
            "__typename": "shoppingCart",
            "userId": 33,
            "productId": 25,
            "productName": "some name",
            "stock": 23,
            "price": 50,
            "user_selected_qantity": 23      <-------- Local Field,
            "is_slected": true                      <-------- Local Field
        }
        ...
    ]
}

This can be achieved seamlessly using two ways.

1- putting the data in to the component "state" and manipulating it.
2- putting the data in to "Redux or other state management library" and manipulate it.

By doing so. aren't we not duplicating the data? one in the redux and one in the cache. should I have to update both?
I was hoping to know the best practice for this use-case using ApolloV3 stuff.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant