Vulcan/packages/nova-core/lib/containers/withCurrentUser.js

31 lines
638 B
JavaScript
Raw Normal View History

import React, { Component } from 'react';
import { graphql } from 'react-apollo';
import gql from 'graphql-tag';
import Users from 'meteor/nova:users';
2017-01-23 11:00:44 +09:00
const withCurrentUser = component => {
const preloadedFields = Users.getPreloadedFields();
return graphql(gql`
query getCurrentUser {
currentUser {
${preloadedFields.join('\n')}
}
}
`, {
2017-01-14 08:29:51 +09:00
alias: 'withCurrentUser',
props(props) {
const {data: {loading, currentUser}} = props;
return {
loading,
currentUser,
};
},
}
)(component);
}
2017-01-23 11:00:44 +09:00
export default withCurrentUser;