Last active
August 29, 2015 14:27
-
-
Save albertstill/358bb2e7385ca02b87b5 to your computer and use it in GitHub Desktop.
This file contains 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 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')} | |
} | |
} | |
} | |
} | |
`, | |
}, | |
}); |
This file contains 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
export default class extends Relay.Route { | |
static path = '/'; | |
static queries = { | |
query: Component => Relay.QL` | |
query getPosts { | |
${Component.getFragment('query')} | |
} | |
` | |
}; | |
static routeName = 'AppHomeRoute'; | |
} |
This file contains 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
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