How to use the @wora/apollo-offline.ApolloClient function in @wora/apollo-offline

To help you get started, we’ve selected a few @wora/apollo-offline 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 morrys / offline-examples / apollo / todo / client / src / apollo / index.js View on Github external
import { ApolloClient } from "@wora/apollo-offline";
import ApolloCache from "@wora/apollo-cache";
import { HttpLink } from "apollo-link-http";

// import ApolloClientIDB from '@wora/apollo-offline/lib/ApolloClientIDB';

const httpLink = new HttpLink({
  uri: "http://localhost:4000/graphql"
});

const cacheOptions = {
  dataIdFromObject: o => o.id
};

const client = new ApolloClient({
  link: httpLink,
  cache: new ApolloCache(cacheOptions)
});

client.setOfflineOptions({
  manualExecution: false, //optional
  link: httpLink, //optional
  start: async mutations => {
    //optional
    console.log("start offline", mutations);
    return mutations;
  },
  finish: async (mutations, error) => {
    //optional
    console.log("finish offline", error, mutations);
  },
github morrys / offline-examples / apollo / react-native / todo / src / apollo / index.js View on Github external
return true;
  },
  onPublish: (offlinePayload) => { //optional
    //const rand = Math.floor(Math.random() * 4) + 1  
    //offlinePayload.serial = rand===1;
    //console.log("offlinePayload", offlinePayload.serial)
    console.log("onPublish offline", offlinePayload)
    return offlinePayload
  }
};

const cacheOptions = {
  dataIdFromObject: o => o.id
};

const client = new ApolloClient({
  link: httpLink,
  cache: new ApolloCache(cacheOptions)
}, offlineOptions);


export default client;

@wora/apollo-offline

@wora Apollo Offline Capabilities

MIT
Latest version published 4 years ago

Package Health Score

45 / 100
Full package analysis