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 { ApolloLink } from "apollo-link";
    import { createHttpLink } from "apollo-link-http";
     
    const httpLink = createHttpLink({ uri: "/graphql" });
    const middlewareLink = new ApolloLink((operation, forward) => {
      operation.setContext({
        headers: {
          authorization: localStorage.getItem("token") || null
        }
      });
      return forward(operation);
    });
     
    // use with apollo-client
    // use with apollo-client
    const link = middlewareLink.concat(httpLink);
    Docs
  • import { ApolloLink } from "apollo-link";
    import { createHttpLink } from "apollo-link-http";
    import { onError } from "apollo-link-error";
     
    import { logout } from "./logout";
     
    const httpLink = createHttpLink({ uri: "/graphql" });
    const errorLink = onError(({ networkError }) => {
      if (networkError.statusCode === 401) {
        logout();
      }
    });
     
    // use with apollo-client
    // use with apollo-client
    const link = errorLink.concat(httpLink);
    Docs
  • import { ApolloLink } from "apollo-link";
    import { createHttpLink } from "apollo-link-http";
     
    const httpLink = createHttpLink({ uri: "/graphql" });
    const addDatesLink = new ApolloLink((operation, forward) => {
      return forward(operation).map(response => {
        if (response.data.user.lastLoginDate) {
          response.data.user.lastLoginDate = new Date(
            response.data.user.lastLoginDate
          );
        }
        return response;
      });
    });
     
    // use with apollo-client
    // use with apollo-client
    const link = addDatesLink.concat(httpLink);
    Docs
  • //...
    import { ApolloCache } from "@wora/apollo-cache";
    import { HttpLink } from "apollo-link-http";
    
    const localIP = "localhost";
    const httpLink = new HttpLink({
      uri: "http://" + localIP + ":3000/graphql",
    });
    
    const cacheOptions = {
      dataIdFromObject: (o) => o.id,
    };
    
    console.log("cache", ApolloCache);
    
    
    
    //...
    
    /morrys/offline-examples mit
  • import { createHttpLink } from "apollo-link-http";
    import ApolloClient from "apollo-client";
    import { InMemoryCache } from "apollo-cache-inmemory";
     
    const client = new ApolloClient({
      link: createHttpLink({ uri: "/graphql" }),
      cache: new InMemoryCache()
    });
     
    // a query with apollo-client
    // a query with apollo-client
    client.query({
      query: MY_QUERY,
      context: {
        // example of setting the headers with context per operation
    // example of setting the headers with context per operation
        headers: {
          special: "Special header value"
        }
      }
    });
    Docs
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples