Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/create-apollo-client / src / cache / apolloCachePersist.ts
Size: Mime:
import { persistCache } from 'apollo-cache-persist'
import { cache } from './apolloCache'

/**
 * @note exported as fn to not make it a side effect
 * @note this is super slow
 * @note was process.env.USE_APOLLO_CACHE
 * @see https://github.com/apollographql/apollo-cache-persist/blob/0bc569308379b4cc59b2c7f5f4823428b208ada0/src/types/index.ts
 */
export default () => {
  if (process.env.NODE_ENV === 'test') {
    // ignore
  } else if (process.env.DISABLE_APOLLO_CACHE_PERSIST !== undefined) {
    console.warn(
      '[create-apollo-client] process.env.DISABLE_APOLLO_CACHE_PERSIST was not undefined'
    )
    return
  } else if (
    typeof window === 'object' &&
    typeof window.localStorage === 'object'
  ) {
    const cacheConfig = {
      cache,
      storage: window.localStorage,
      key: 'graphql-client-cache',
    }

    /**
     * @note this returns a promise
     */
    persistCache(cacheConfig)
  } else {
    // is server
  }
}