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

  • import { ApolloClient, InMemoryCache } from '@apollo/client';
    
    const client = new ApolloClient({
      cache: new InMemoryCache(),
      resolvers: {
        Mutation: {
          updateUserEmail: (_, { id, email }, { cache }) => {
            cache.writeFragment({
              id: cache.identify({ __typename: "User", id }),
              fragment: gql`fragment UserEmail on User { email }`,
              data: { email },
            });
          },
        },
      },
    };
    Docs
  • import { ApolloClient, InMemoryCache } from '@apollo/client';
    
    const client = new ApolloClient({
      resolvers: {
        Mutation: {
          toggleTodo: (_, variables, { cache }) => {
            const id = `TodoItem:${variables.id}`;
            const fragment = gql`
              fragment CompleteTodo on TodoItem {
                completed
              }
            `;
            const todo = cache.readFragment({ fragment, id });
            const data = { ...todo, completed: !todo.completed };
    
            cache.writeFragment({ fragment, id, data });
            return null;
          },
        },
      },
    });
    Docs
  • import { ApolloClient, InMemoryCache } from '@apollo/client';
    
    const client = new ApolloClient({
      cache: new InMemoryCache({
        typePolicies: {
          Query: {
            fields: {
              book: {
                read(_, { args, toReference }) {
                  return toReference({
                    __typename: 'Book',
                    id: args.id,
                  });
                }
              }
            }
          }
        }
      })
    });
    Docs
  • import { ApolloClient, InMemoryCache } from '@apollo/client';
    
    const client = new ApolloClient({
      cache: new InMemoryCache(),
      resolvers: {
        Mutation: {
          toggleTodo: (_root, variables, { cache }) => {
            cache.modify({
              id: cache.identify({
                __typename: 'TodoItem',
                id: variables.id,
              }),
              fields: {
                completed: value => !value,
              },
            });
            return null;
          },
        },
      },
    });
    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
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples