How to use the apollo-cache-persist.persistCache function in apollo-cache-persist

To help you get started, we’ve selected a few apollo-cache-persist examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github celo-org / celo-monorepo / packages / verifier / src / services / Apollo.ts View on Github external
kind: 'UNION',
        name: 'Event',
        possibleTypes: [{ name: 'Transfer' }],
      },
    ],
  },
}

const fragmentMatcher = new IntrospectionFragmentMatcher({
  introspectionQueryResultData,
})

const cache = new InMemoryCache({ fragmentMatcher })

// TODO what should happen if this fails???
persistCache({
  cache,
  storage: AsyncStorage,
}).catch((err) => {
  console.error('Apollo.persistCache error', err)
})

export const apolloClient = new ApolloClient({
  uri: BLOCKCHAIN_API_URL,
  cache,
})
github celo-org / celo-monorepo / packages / mobile / src / apollo / index.ts View on Github external
import AsyncStorage from '@react-native-community/async-storage'
import ApolloClient from 'apollo-boost'
import { InMemoryCache, IntrospectionFragmentMatcher } from 'apollo-cache-inmemory'
import { persistCache } from 'apollo-cache-persist'
import introspectionQueryResultData from 'src/apollo/fragmentTypes.json'
import config from 'src/geth/networkConfig'
import Logger from 'src/utils/Logger'

const fragmentMatcher = new IntrospectionFragmentMatcher({
  introspectionQueryResultData,
})

const cache = new InMemoryCache({ fragmentMatcher })

persistCache({
  cache,
  // @ts-ignore https://github.com/apollographql/apollo-cache-persist/pull/58
  storage: AsyncStorage,
}).catch((reason: string) => Logger.error('Apollo/index', `Failure to persist cache: ${reason}`))

export const apolloClient = new ApolloClient({
  uri: config.blockchainApiUrl,
  cache,
})
github NERDDISCO / luminave / src / components / graphql / graphql-client.js View on Github external
// WebSocket connection
  const websocketLink = new WebSocketLink({ 
    uri: url, 
    options: {
      reconnect
    } 
  })

  // Stitch different links together
  const link = ApolloLink.from([
    websocketLink
  ])

  // Cache
  const cache = new InMemoryCache().restore(window.__APOLLO_STATE__)
  await persistCache({
    cache, 
    storage: window.localStorage 
  })

  // Create a new client
  client = new ApolloClient({ cache, link, ssrForceFetchDelay: 100, debug: true })

  return client
}
github NERDDISCO / luminave / src / components / integration / integration-graphql.js View on Github external
this.connected = false
      this.connectionStatus = 'error'
      const { connected, connectionStatus } = this

      this.dispatchEvent(new CustomEvent('connection-error', { detail: { connected, error, connectionStatus } }))
    }, this)

    // Stitch different links together
    const link = ApolloLink.from([
      this.websocketLink
    ])

    // Cache
    const cache = new InMemoryCache().restore(window.__APOLLO_STATE__)
    await persistCache({
      cache, 
      storage: window.localStorage 
    })

    // Create a new client
    this.client = new ApolloClient({ cache, link, ssrForceFetchDelay: 100, debug: true })
  }
github Jordaneisenburger / fallback-studio / src / pwa-studio / packages / venia-concept / src / drivers / adapter.js View on Github external
static apolloCache() {
        const cache = new InMemoryCache();

        persistCache({
            cache,
            storage: window.localStorage
        });

        return cache;
    }
    static apolloClient({ apiBase, apollo: { cache, link } = {} }) {
github tsirlucas / soundplace / src / core / apollo / Client.ts View on Github external
private async generateClient() {
    const cache = new InMemoryCache();

    await persistCache({
      cache,
      storage: localforage,
    });

    const wsLink = new WebSocketLink({
      uri: this.socketUrl,
      options: {
        reconnect: true,
        timeout: 30000,
        connectionParams: async () => ({
          authorization: await localforage.getItem('token'),
        }),
      },
    });

    const link = ApolloLink.from([
github zenika-open-source / FAQ / client / src / index.js View on Github external
import React from 'react'
import ReactDOM from 'react-dom'
import { BrowserRouter } from 'react-router-dom'
import { ApolloProvider } from '@apollo/react-hooks'
import { persistCache } from 'apollo-cache-persist'

import { apollo, apolloCache } from 'services'

import 'normalize.css'

import App from './scenes/App'

persistCache({
  cache: apolloCache,
  storage: window.localStorage
}).then(() => {
  ReactDOM.render(
    
      
        
      
    ,
    document.getElementById('root')
  )
})

apollo-cache-persist

Simple persistence for all Apollo cache implementations

MIT
Latest version published 7 years ago

Package Health Score

62 / 100
Full package analysis

Similar packages