Skip to content

Instantly share code, notes, and snippets.

@hwillson
Last active February 19, 2019 21:10
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/3ba87d1943831db1a4cebbaf565af3cb to your computer and use it in GitHub Desktop.
Save hwillson/3ba87d1943831db1a4cebbaf565af3cb to your computer and use it in GitHub Desktop.
Apollo Client - 2.5.0 Announcement Post - @client(always: true)
import { ApolloClient } from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import gql from 'graphql-tag';
const client = new ApolloClient({
cache: new InMemoryCache(),
resolvers: {
User: {
isLoggedIn() {
return !!localStorage.getItem('token');
},
},
},
});
const USER_DETAILS = gql`
query UserDetails {
user {
username
isLoggedIn @client(always: true)
}
}
`;
// ... run the query using client.query, a <Query /> component, etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment