Skip to content

Instantly share code, notes, and snippets.

@albertstill
Last active August 29, 2015 14:27
Show Gist options
  • Save albertstill/358bb2e7385ca02b87b5 to your computer and use it in GitHub Desktop.
Save albertstill/358bb2e7385ca02b87b5 to your computer and use it in GitHub Desktop.
import Post from './Post';
class App extends React.Component {
render() {
return (
<div>
<h1>Post list</h1>
<ul>
{this.props.posts.edges.map(edge =>
<Post key={edge.node.id} post={edge.node} />
)}
</ul>
</div>
);
}
}
export default Relay.createContainer(App, {
fragments: {
query: () => Relay.QL`
fragment on Query {
posts {
edges {
node {
id
${Post.getFragment('post')}
}
}
}
}
`,
},
});
export default class extends Relay.Route {
static path = '/';
static queries = {
query: Component => Relay.QL`
query getPosts {
${Component.getFragment('query')}
}
`
};
static routeName = 'AppHomeRoute';
}
class Post extends React.Component {
render() {
return (
<div>
<h1>{this.props.post.title}</h1>
<p>{this.props.post.body}</p>
</div>
);
}
}
export default Relay.createContainer(Post, {
fragments: {
post: () => Relay.QL`
fragment on Post {
title
body
}
`
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment