summaryrefslogtreecommitdiffstats
path: root/finished-application/frontend/components/User.js
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-09-14 12:18:12 -0400
committerWes Bos <wesbos@gmail.com>2018-09-14 12:18:12 -0400
commit2d145b026cfdf54a63bef0b9d6324b6785390307 (patch)
treef6c1d8f987437803a5c026e70535bf9ff244e885 /finished-application/frontend/components/User.js
parent8a5825d52271d712ec7c8348447d433067e13ef2 (diff)
move finished folder
Diffstat (limited to 'finished-application/frontend/components/User.js')
-rw-r--r--finished-application/frontend/components/User.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/finished-application/frontend/components/User.js b/finished-application/frontend/components/User.js
new file mode 100644
index 0000000..6f8a4fb
--- /dev/null
+++ b/finished-application/frontend/components/User.js
@@ -0,0 +1,41 @@
+import { Query } from 'react-apollo';
+import gql from 'graphql-tag';
+import PropTypes from 'prop-types';
+
+const CURRENT_USER_QUERY = gql`
+ query {
+ me {
+ id
+ email
+ name
+ permissions
+ orders {
+ id
+ }
+ cart {
+ id
+ quantity
+ item {
+ id
+ price
+ image
+ title
+ description
+ }
+ }
+ }
+ }
+`;
+
+const User = props => (
+ <Query {...props} query={CURRENT_USER_QUERY}>
+ {payload => props.children(payload)}
+ </Query>
+);
+
+User.propTypes = {
+ children: PropTypes.func.isRequired,
+};
+
+export default User;
+export { CURRENT_USER_QUERY };