How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • 
    
    const client = new ApolloClient({
      link: ApolloLink.from([
        onError(({ graphQLErrors, networkError }) => {
          if (graphQLErrors) {
            graphQLErrors.map(({ message, locations, path, extensions }) => {
              if(extensions.code === 'UNAUTHENTICATED') {
                localStorage.removeItem('jwt');
                client.resetStore();
              }
              console.log(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`);
            });
            if (networkError) {
              console.log(`[Network error]: ${networkError}`);
            }
          }
        }),
        InfoLink,
        AuthLink,
        link
      ]),
      cache: new InMemoryCache().restore(window.__APOLLO_STATE__)
    });
    
    
    /PacktPublishing/Hands-on-Full-Stack-Web-Development-with-GraphQL-and-React MIT
  • import { AsyncStorage } from 'react-native';
    import { InMemoryCache } from '@apollo/client';
    import { persistCache } from 'apollo3-cache-persist';
    
    const cache = new InMemoryCache();
    
    persistCache({
      cache,
      storage: AsyncStorage,
    }).then(() => {
      // Continue setting up Apollo Client as usual.
    })
    Docs
  • import { ApolloClient, InMemoryCache } from '@apollo/client';
    
    const cache = new InMemoryCache();
    const client = new ApolloClient({
      cache,
      resolvers: { /* ... */ },
    });
    
    function writeInitialData() {
      cache.writeQuery({
        query: gql`
          query GetTodosNetworkStatusAndFilter {
            todos
            visibilityFilter
            networkStatus {
              isConnected
            }
          }
        `,
        data: {
          todos: [],
          visibilityFilter: 'SHOW_ALL',
          networkStatus: {
            __typename: 'NetworkStatus',
            isConnected: false,
          },
        },
      });
    }
    
    writeInitialData();
    
    client.onResetStore(writeInitialData);
    Docs
  • import { ApolloClient, InMemoryCache } from '@apollo/client';
    import { withClientState } from 'apollo-link-state';
    
    import { resolvers, defaults } from './resolvers';
    
    const cache = new InMemoryCache();
    const stateLink = withClientState({ cache, resolvers, defaults });
    
    const client = new ApolloClient({
      cache,
      link: stateLink,
    });
    
    client.onResetStore(stateLink.writeDefaults);
    Docs
  • export default withApollo(graphql(PROFILE_QUERY, {
      props: ({ data: { loading, currentUser }, ownProps: { client }}) => ({
        loading,
        currentUser,
        resetOnLogout: async () => client.resetStore(),
      }),
    })(Profile));
    Docs
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples