Yes, you can get multiple snippets for each component. My suggestion here would be to have a separate snippet for the selected message and use it in a route designed to present the details of the record (permalink).
First add a snippet to represent the selected message.
export default Relay.createContainer(PostList, {
initialVariables: {
count: 10,
},
fragments: {
selectedPost: () => Relay.QL`
fragment on Post {
id
title
description
}
`,
viewer: () => Relay.QL`
fragment on Viewer {
posts(first: $count) {
edges {
node {
id
title
}
}
}
}
`,
},
});
. , .
class IndexRoute extends Relay.Route {
static queries = {
viewer: () => Relay.QL`query { viewer }`,
};
static routeName = 'IndexRoute';
}
class PostPermalinkRoute extends Relay.Route {
static queries = {
selectedPost: () => Relay.QL`query { node(id: $postID) }`,
viewer: () => Relay.QL`query { viewer }`,
};
static paramDefinitions = {
postID: {required: true},
};
static routeName = 'PostPermalinkRoute';
}
, , permalink. Relay , , , .
function render(route) {
ReactDOM.render(
<Relay.RootContainer
Component={PostList}
route={route}
/>,
container,
);
}
// When it time to render the index...
render(new IndexRoute());
// Upon selecting a post...
render(new PostPermalinkRoute({postID: 123}));
this.props.relay.route, , this.props.relay.route.name this.props.relay.route.params.