import React, { Component } from 'react';
import {graphql} from 'react-apollo';
import {getUserProfileQuery} from '../queries/queries';
class UserProfile extends Component {
displayUserProfile(){
const {user} = this.props.data;
if(user){
return(
{ user.alias }
{ user.firstName }
{ user.lastName }
{ user.role.name }
);
} else {
return( No User selected...
);
}
}
render() {
return (
{this.displayUserProfile()}
);
}
}
export default graphql(getUserProfileQuery, { // What follows is the way to pass a parameter to a query.
options: (props) => {
return {
variables: {
id: props.userId
}
}
}
})(UserProfile); // This binds the querty to the component