Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { ApolloClient } from 'apollo-client';
- import { InMemoryCache } from 'apollo-cache-inmemory';
- import gql from 'graphql-tag';
- const client = new ApolloClient({
- cache: new InMemoryCache(),
- resolvers: {
- Query: {
- isLoggedIn() {
- return !!localStorage.getItem('token');
- },
- },
- },
- });
- const IS_LOGGED_IN = gql`
- query IsUserLoggedIn {
- isLoggedIn @client(always: true)
- }
- `;
- // ... run the query using client.query, a <Query /> component, etc
Add Comment
Please, Sign In to add comment