title: GraphQL Dataloader not knowing keys in advance
body: <p>Dataloader is able to batch and cache requests, but it can only be used by either calling load(key) or loadMany(keys). </p>
  
  <p>The problem I am having is that sometimes I do not know they keys of the items I want to load in advance.</p>
  
  <p>I am using an sql database and this works fine when the current object has a foreign key from a belongsTo relation with another model. </p>
  
  <p>For example a user that belongs to a group and so has a groupId. To resolve the group you would just call groupLoader.load(groupId).</p>
  
  <p>On the other hand, if I wanted to resolve the users within a group, of which there could be many I would want a query such as </p>
  
  <pre><code>SELECT * from users where user.groupId = theParticularGroupId
  </code></pre>
  
  <p>but a query such as this doesn't use the keys of the users and so I am not sure how make use of dataloader.</p>
  
  <p>I could do another request to get the keys like</p>
  
  <pre><code>SELECT id from users where user.groupId = theParticularGroupId
  </code></pre>
  
  <p>and then call loadMany with those keys... But I could have just requested the data directly instead.</p>
  
  <p>I noticed that dataloader has a prime(key, value) function which can be used to prime the cache, however that can only be done once the data is already fetched. At which point many queries would already have been sent, and duplicate data could have been fetched.</p>
  
  <hr>
  
  <p>Another example would be the following query</p>
  
  <pre><code>query {
    groups(limit: 10) {
      id
      ...
      users {
        id
        name
        ...
      }
    }
  }
  </code></pre>
  
  <p>I cannot know the keys if I am searching for say the first or last 10 groups. Then once I have these 10 groups. I cannot know the keys of their users, and if each resolver would resolve the users using a query such as </p>
  
  <pre><code>SELECT * from users where user.groupId = theParticularGroupId
  </code></pre>
  
  <p>that query will be executed 10 times. Once the data is loaded I could now prime the cache, but the 10 requests have already been made.</p>
  
  <p>Is there any way around this issue? Perhaps a different pattern or database structure or maybe dataloader isn't even the right solution.</p>