Skip to content

Instantly share code, notes, and snippets.

@frikille
Created July 19, 2015 22:43
Show Gist options
  • Save frikille/8d8607f0318139d295d1 to your computer and use it in GitHub Desktop.
Save frikille/8d8607f0318139d295d1 to your computer and use it in GitHub Desktop.
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