import React, { Component } from 'react' import {graphql, compose} from 'react-apollo' import {getUserProfileQuery} from '../queries/queries' // Materia UI import { withStyles } from '@material-ui/core/styles' import Grid from '@material-ui/core/Grid' import Card from '@material-ui/core/Card' import CardActionArea from '@material-ui/core/CardActionArea' import CardContent from '@material-ui/core/CardContent' import CardMedia from '@material-ui/core/CardMedia' import Typography from '@material-ui/core/Typography' import Divider from '@material-ui/core/Divider' // Images import PortraitImage from '../img/portrait.jpg' const styles = theme => ({ root: { flexGrow: 1, padding: 60, margin: 2 }, card: { width: '80%', paddingTop: '30' }, media: { height: 0, paddingTop: '56.25%', // 16:9, marginTop: '30', minWidth: '80%' }, grid: { paddingTop: '30', marginTop: '30' }, typography: { width: '100%', marginTop: 20, marginBottom: 20 } }) class UserProfile extends Component { displayUserProfile () { const user = this.props.data.users_User const { classes } = this.props if (user) { return ( { this.setState({ selected: user.id}) } }> { user.firstName } { user.lastName } ( {user.alias} ) { user.role.name } { user.bio } ) } else { return (
No User selected...
) } } render () { return ( {this.displayUserProfile()} ) } } export default compose( graphql(getUserProfileQuery, { // What follows is the way to pass a parameter to a query. options: (props) => { return { variables: { name: 'getUserProfileQuery', id: props.userId } } }}), withStyles(styles) )(UserProfile) // This technique binds more than one query to a single component.