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, HttpLink, InMemoryCache } from "@apollo/client";
    import { RetryLink } from "@apollo/client/link/retry";
    
    const directionalLink = new RetryLink().split(
      (operation) => operation.getContext().version === 1,
      new HttpLink({ uri: "http://localhost:4000/v1/graphql" }),
      new HttpLink({ uri: "http://localhost:4000/v2/graphql" })
    );
    
    const client = new ApolloClient({
      cache: new InMemoryCache(),
      link: directionalLink,
    });
    Docs
  • import { ApolloLink, HttpLink } from '@apollo/client';
    import { RetryLink } from '@apollo/client/link/retry';
    
    const directionalLink = new RetryLink().split(
      (operation) => operation.getContext().version === 1,
      new HttpLink({ uri: "http://localhost:4000/v1/graphql" }),
      new HttpLink({ uri: "http://localhost:4000/v2/graphql" })
    );
    Docs
  • import { ApolloClient, InMemoryCache } from '@apollo/client';
    
    // ...code from the above example goes here...
    
    const client = new ApolloClient({
      link: splitLink,
      cache: new InMemoryCache()
    });
    Docs
  • import { split, HttpLink } from '@apollo/client';
    import { getMainDefinition } from '@apollo/client/utilities';
    import { GraphQLWsLink } from '@apollo/client/link/subscriptions';
    import { createClient } from 'graphql-ws';
    
    const httpLink = new HttpLink({
      uri: 'http://localhost:4000/graphql'
    });
    
    const wsLink = new GraphQLWsLink(createClient({
      url: 'ws://localhost:4000/subscriptions',
    }));
    
    // The split function takes three parameters:
    //
    // * A function that's called for each operation to execute
    // * The Link to use for an operation if the function returns a "truthy" value
    // * The Link to use for an operation if the function returns a "falsy" value
    const splitLink = split(
      ({ query }) => {
        const definition = getMainDefinition(query);
        return (
          definition.kind === 'OperationDefinition' &&
          definition.operation === 'subscription'
        );
      },
      wsLink,
      httpLink,
    );
    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
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples