1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
Relay.createContainer(Story, {
initialVariables: {
numCommentsToShow: 10,
showComments: false,
},
fragments: {
story: (variables) => Relay.QL`
fragment on Story {
comments(first: $numCommentsToShow) @include(if: $showComments) {
edges {
node {
author { name },
id,
text,
},
},
},
}
`,
}
});
// An inline fragment - useful in small quantities, but best not to share
// between modules.
var userFragment = Relay.QL`
fragment on User {
name,
}
`;
Relay.createContainer(Story, {
fragments: {
bar: () => Relay.QL`
fragment on Story {
author {
# Fetch the same information about the story's author ...
${userFragment},
},
comments {
edges {
node {
author {
# ... and the authors of the comments.
${userFragment},
},
},
},
},
}
`,
}
});
|