How to use the apollo-client-preset.ApolloLink.from function in apollo-client-preset

To help you get started, we’ve selected a few apollo-client-preset 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 bechurch / link_state_demo / src / Client.js View on Github external
import {InMemoryCache} from 'apollo-cache-inmemory';
import {ApolloLink} from 'apollo-client-preset';
import {ApolloClient} from 'apollo-client';
import CreateClientStore from './CreateClientStore';

// Set up Cache
const cache = new InMemoryCache();

// Set up Local State
const stateLink = CreateClientStore(cache);

// Initialize the Apollo Client
const Client = new ApolloClient({
  link: ApolloLink.from([
    stateLink,
  ]),
  cache: cache,
});

export default Client;
github LFSCamargo / Chatify / packages / app / src / config / client.ts View on Github external
updateNetworkStatus: (_, { isConnected }, { cache }) => {
        const data = {
          networkStatus: {
            __typename: 'NetworkStatus',
            isConnected,
          },
        }
        cache.writeData({ data })
        return null
      },
    },
  },
})

const client = new ApolloClient({
  link: ApolloLink.from([stateLink, authLink.concat(link)]),
  cache,
})

export default client
github department-stockholm / apollo-component / examples / next-cms / components / withApollo.js View on Github external
const createClient = (opts = {}, state) => {
  const client = new ApolloClient({
    link: ApolloLink.from([logs(opts), auth(opts), http(opts)]),
    ...opts
  });

  if (state) {
    client.cache.restore(state);
  }
  return client;
};
github department-stockholm / apollo-component / examples / next / components / withApollo.tsx View on Github external
const createClient = (opts: { ssrMode?: boolean; token?: string }, state?) => {
  const client = new ApolloClient({
    link: ApolloLink.from([logs(opts), auth(opts), http(opts)]),
    ...opts
  });

  if (state) {
    client.cache.restore(state);
  }
  return client;
};
github ahmedlhanafy / guchub / src / utils / setupApollo.js View on Github external
export default async () => {
  const cacheSchemaVersion = (await getSchemaVersion()) || 0;
  if (currentSchemaVersion === cacheSchemaVersion) {
    await persistor.restore();
  } else {
    await persistor.purge();
    await saveSchemaVersion(currentSchemaVersion);
  }

  const clientStateLink = await generateClientStateLink(cache);
  return new ApolloClient({
    connectToDevTools: process.env.NODE_ENV === 'development',
    link: ApolloLink.from([
      clientStateLink,
      new HttpLink({
        uri: 'https://graphql-guc.now.sh/graphql',
      }),
    ]),
    cache,
  });
};