Apollo Client no-cache

node v8.11.1
version: 4.0.1
endpointsharetweet
require('isomorphic-fetch') require('graphql') const { ApolloClient } = require('apollo-client') const { HttpLink } = require('apollo-link-http') const { InMemoryCache } = require('apollo-cache-inmemory') const gql = require('graphql-tag') const uri = 'https://graphql-pokemon.now.sh/graphql' const query = gql`{ pokemon(name: "Pikachu") { id number name } }`
const client = new ApolloClient({ link: new HttpLink({uri}), cache: new InMemoryCache() }) client.query({query}) .then(data => console.log(data)) .catch(error => console.error(error))
const clientNoCache = new ApolloClient({ link: new HttpLink({uri}), cache: new InMemoryCache() }) clientNoCache.query({query, fetchPolicy: 'no-cache'}) .then(data => console.log(data)) .catch(error => console.error(error))
const clientNetworkOnly = new ApolloClient({ link: new HttpLink({uri}), cache: new InMemoryCache() }) clientNoCache.query({query, fetchPolicy: 'network-only'}) .then(data => console.log(data)) .catch(error => console.error(error))
Loading…

no comments

    sign in to comment