Guest User

Untitled

a guest
Feb 18th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. import { ApolloClient } from 'apollo-client';
  2. import { InMemoryCache } from 'apollo-cache-inmemory';
  3. import gql from 'graphql-tag';
  4.  
  5. const client = new ApolloClient({
  6. cache: new InMemoryCache(),
  7. resolvers: {
  8. Query: {
  9. isLoggedIn() {
  10. return !!localStorage.getItem('token');
  11. },
  12. },
  13. },
  14. });
  15.  
  16. const IS_LOGGED_IN = gql`
  17. query IsUserLoggedIn {
  18. isLoggedIn @client(always: true)
  19. }
  20. `;
  21.  
  22. // ... run the query using client.query, a <Query /> component, etc
Add Comment
Please, Sign In to add comment