How to use the @apollo/client.InMemoryCache function in @apollo/client

To help you get started, we’ve selected a few @apollo/client 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 minskylab / supersense / observer / pages / _app.tsx View on Github external
: null;

const splitLink = process.browser
    ? split(
          ({ query }) => {
              const definition = getMainDefinition(query);
              return definition.kind === "OperationDefinition" && definition.operation === "subscription";
          },
          wsLink,
          httpLink
      )
    : httpLink;

const client = new ApolloClient({
    link: splitLink,
    cache: new InMemoryCache(),
});

const SupersenseApp = ({ Component, pageProps }: AppProps) => {
    return (
        
            
                
            
        
    );
};

// Only uncomment this method if you have blocking data requirements for
// every single page in your application. This disables the ability to
// perform automatic static optimization, causing every page in your app to
// be server-side rendered.
github Shopify / next-gen-auth-app-demo / app / javascript / components / App.js View on Github external
export default function App() {
  const client = new ApolloClient({
    link: new HttpLink({
      credentials: 'same-origin',
      fetch: authenticatedFetch(window.app), // created in shopify_app.js
      uri: '/graphql'
    }),
    cache: new InMemoryCache()
  });

  return (
github minskylab / supersense / observer / src / App.tsx View on Github external
const splitLink = split(
    ({ query }) => {
        const definition = getMainDefinition(query);
        return (
            definition.kind === "OperationDefinition" &&
            definition.operation === "subscription"
        );
    },
    wsLink,
    httpLink,
);

const client = new ApolloClient({
    link: splitLink,
    cache: new InMemoryCache(),
});

interface AppProps {}

function App({}: AppProps) {
    return (
        
            
                
                    
                        
                    
                
            
        
    );
github apollographql / apollo-tooling / packages / apollo / src / NewCommand.tsx View on Github external
.then(config => {
            if (!config) throw new Error("Could not load config");
            const client = new ApolloClient({
              name: "Apollo CLI",
              version,
              link: new HttpLink({
                uri: config.engine.endpoint,
                headers: {
                  "x-api-key": config.engine.apiKey || service,
                  "apollo-client-reference-id": referenceID
                },
                fetch: fetch as any
              }),
              cache: new InMemoryCache()
            });
            setCommandReady({
              client,
              config,
              oclif
            });
          })
          .catch(e => console.error(e));
github MichaelMure / git-bug / webui / src / apollo.ts View on Github external
import { ApolloClient, InMemoryCache } from '@apollo/client';

import introspectionResult from './fragmentTypes';

const client = new ApolloClient({
  uri: '/graphql',
  cache: new InMemoryCache({
    possibleTypes: introspectionResult.possibleTypes,
  }),
});

export default client;
github dstotijn / hetty / admin / src / lib / graphql.ts View on Github external
function createApolloClient() {
  return new ApolloClient({
    ssrMode: typeof window === "undefined",
    link: new HttpLink({
      uri: "/api/graphql/",
    }),
    cache: new InMemoryCache({
      typePolicies: {
        Project: {
          keyFields: ["name"],
        },
      },
    }),
  });
}
github daniman / redux-to-apollo / src / index.js View on Github external
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router } from 'react-router-dom';
import App from './App';
import keys from './keys';
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';

const client = new ApolloClient({
  uri: 'https://api.github.com/graphql',
  headers: {
    authorization: `bearer ${keys.github}`
  },
  cache: new InMemoryCache()
});

ReactDOM.render(
  
    
      
    
  ,
  document.getElementById('root')
);
github apollographql / apollo-client / examples / bundling / tree-shaking / rollup-ac3-no-react / src / index.js View on Github external
import { ApolloClient, InMemoryCache, gql } from "@apollo/client";

const ALL_COUNTRIES = gql`
  query AllCountries {
    countries @client {
      code
      name
      emoji
    }
  }
`;

const client = new ApolloClient({
  cache: new InMemoryCache(),
  resolvers: {
    Query: {
      countries() {
        return [
          {
            code: "AD",
            emoji: "🇦🇩",
            name: "Andorra",
            __typename: "Country"
          },
          {
            code: "AE",
            emoji: "🇦🇪",
            name: "United Arab Emirates",
            __typename: "Country"
          }