Using Relay and GraphQL, let's say that I have a schema that returns a viewer, and a built-in list of related documents. The root query (consisting of fragments) will look something like this:
query Root {
viewer {
id,
name,
groups {
edges {
node {
id,
name,
}
}
}
}
}
This will allow me to display the user and a list of all groups associated with him.
Now let me say that I want the user to be able to click on this list item and expand it to show comments related to this particular list item. How should I restructure my request for a relay route to receive these comments? If I add the comment edge to the edge of my groups, will it not receive comments for all groups?
query Root {
viewer {
id,
name,
groups {
edges {
node {
id,
name,
comments {
edges {
node {
id,
content
}
}
}
}
}
}
}
}
, ?
query Root {
group(id: "someid"){
id,
name,
comments {
edges {
node {
id,
content
}
}
}
},
viewer {
id,
name,
groups {
edges {
node {
id,
name,
}
}
}
}
}
, , relay. I.e., , ( ), , , ? , , , .