0

Let's say I have a list of shrinked items with users ID. By clicking on them I want to lazy load data with apollo query, expand and show received data, for example username, address, etc. So how should I "cache" or store this data locally, to be able to reload + append new user data and also show already loaded users from local state, not reloading them from server

Hypothetical query with hypothetical behavior:

export default {
    apollo: {
        getUser: {
            query: gpl`query getUser($id: Int!) {
                getUser(id: $id) {
                    username
                    address
                }
            }`,
            onDataLoaded: data => this.storedUsers.concat(data) // smthg lk ths
        }
    },
    data () {
        return {
             storedUsers: []
        }
    }
}

Or maybe this is a bad approach?

1 Answers1

0

Apollo Client has an InMemoryCache and does not reload the data unless you say so. See https://www.apollographql.com/docs/react/caching/cache-configuration/

Janning Vygen
  • 8,877
  • 9
  • 71
  • 102