title: fetching additional information for a particular list item in relay/graphql
body: <p>Using Relay and GraphQL, let's say that I have a schema that returns a viewer, and an embedded list of associated documents. The root query (composed with fragments) would look like something like this:</p>
  
  <pre><code>query Root {
    viewer {
      id,
      name,
      groups {
        edges {
          node {
            id,
            name,
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>This will allow me to display the user, and a list of all of its associated groups. </p>
  
  <p>Now let's say that I want the user to be able to click on that list item, and have it expand to show the comments associated with that particular list item. How should I restructure my query for the relay route such that I can receive those comments? If I add a comments edge to my groups edge, then won't it fetch the comments for all of the groups?</p>
  
  <pre><code>query Root {
    viewer {
      id,
      name,
      groups {
        edges {
          node {
            id,
            name,
            comments {
              edges {
                node {
                  id,
                  content
                }
              }
            }
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>Or should I alter the route query to find a specific group?</p>
  
  <pre><code>query Root {
    group(id: "someid"){
      id,
      name,
      comments {
        edges {
          node {
            id,
            content
          }
        }
      }
    },
    viewer {
      id,
      name,
      groups {
        edges {
          node {
            id,
            name,
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>My concern is, in particular, using this within the context of <code>relay</code>. I.e., how can I efficiently construct a route query that will only fetch the comments for the expanded list item (or items), while still taking advantage of the cached data that already exists, and will be updated when doing mutations? The above example might work for a specific expanded group, but I'm not sure how I could expand multiple groups simultaneously without fetching those fields for <em>all</em> of the group items. </p>