Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
Apollo Client no-cache
node v8.17.0
version:
4.0.1
endpoint
share
tweet
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