import React from 'react' import { withRouter } from 'next/router' import { graphql } from 'react-apollo' import gql from 'graphql-tag' import ErrorMessage from './ErrorMessage' import PostVoteUp from './PostVoteUp' import PostVoteDown from './PostVoteDown' import PostVoteCount from './PostVoteCount' function Post ({ id, data: { error, Post } }) { if (error) return if (Post) { return (

{Post.title}

ID: {Post.id}
URL: {Post.url}

) } return
Loading
} const post = gql` query post($id: ID!) { Post(id: $id) { id title votes url createdAt } } ` // The `graphql` wrapper executes a GraphQL query and makes the results // available on the `data` prop of the wrapped component (PostList) const ComponentWithMutation = graphql(post, { options: ({ router: { query } }) => ({ variables: { id: query.id } }), props: ({ data }) => ({ data }) })(Post) export default withRouter(ComponentWithMutation)