Skip to content

Instantly share code, notes, and snippets.

@wking-io
Last active October 4, 2017 16:46
Show Gist options
  • Save wking-io/a8f5aafd0824bd8ffa1afc7a02e687df to your computer and use it in GitHub Desktop.
Save wking-io/a8f5aafd0824bd8ffa1afc7a02e687df to your computer and use it in GitHub Desktop.
Check User Auth Component
import React from 'react'
import { graphql, gql } from 'react-apollo';
import storage from 'store';
const isLoggedIn = ({ children, user }) => {
if(user) {
return children;
}
};
const USER_QUERY = gql`
query allUser($id: ID!) {
user(id: $id) {
id
}
}
`;
// Use store package to grab users id from local storage and return the id if
// it is in graphcool. If not it will return null.
export default graphql(USER_QUERY, {
name: 'user',
options: { variables: { id: storage.get(GC_USER_ID) } },
})(isLoggedIn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment