Skip to content

Instantly share code, notes, and snippets.

@hwillson
Created February 26, 2019 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hwillson/7b4c5e2452f3c703359e665a41dfad15 to your computer and use it in GitHub Desktop.
Save hwillson/7b4c5e2452f3c703359e665a41dfad15 to your computer and use it in GitHub Desktop.
Apollo Client - 2.5.0 - Resolver
const client = new ApolloClient({
cache: new InMemoryCache(),
link: new HttpLink({
uri: 'http://localhost:4000/graphql',
}),
resolvers: {
Launch: {
isInCart: (launch, _args, { cache }) => {
const { cartItems } = cache.readQuery({
query: GET_CART_ITEMS
});
return cartItems.includes(launch.id);
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment