You can use the autoRehydrate function redux-persist . It will trigger an action with the REHYDRATE type REHYDRATE , which will rehydrate all stores if you do not blacklist them.
If you try to fulfill a request that was previously executed, Apollo will first check your Redux store and you will see the APOLLO_QUERY_RESULT_CLIENT action (this means that it returns from the client store instead of the request to the server). You can modify fetchPolicy to indicate how the request receives its data (network only, cache first, etc.)
Here is the basic setup:
import React, { Component } from 'react'; import { ApolloProvider } from 'react-apollo'; import { createStore, combineReducers, applyMiddleware, compose } from 'redux'; import ApolloClient, { createNetworkInterface } from 'apollo-client'; import { persistStore, autoRehydrate } from 'redux-persist'; import { AsyncStorage } from 'react-native'; const networkInterface = createNetworkInterface({ uri: 'http://localhost:8080/graphql' }); export const client = new ApolloClient({ networkInterface: networkInterface, }); const store = createStore( combineReducers({ apollo: client.reducer(), }), {},
source share