Created
July 19, 2015 22:43
-
-
Save frikille/8d8607f0318139d295d1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { GQLQuery } from './GQLQuery.js'; | |
@GQLQuery | |
class CommentsAndLikes extends React.Component { | |
static queries = { | |
commentAndLikes() { | |
return ` | |
likes { | |
id, | |
user { | |
id | |
} | |
}, | |
comments { | |
id, | |
user { | |
id, | |
username, | |
avatar_url | |
} | |
}`; | |
} | |
} | |
render() { | |
return ( | |
// render function implementation | |
); | |
} | |
} | |
class Post extends React.Component { | |
static queries = { | |
main() { | |
return ` | |
post(journal: <journal>, post: <post>) { | |
id, | |
title, | |
slug, | |
author { | |
username | |
}, | |
journal { | |
slug | |
}, | |
${CommentsAndLikes.getQuery('commentsAndLikes')} | |
}`; | |
} | |
} | |
render() { | |
return ( | |
<div> | |
<div> | |
{/* Post page layout, title only for now */} | |
{this.props.data.getIn(['post', 'title'])} | |
</div> | |
<CommentsAndLikes comments={this.props.data.getIn(['post', 'comments'])} likes={this.props.data.get(['post', 'likes'])} /> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment