title: howto resolve fields from multiple datasources in GraphQL
body: <p>A beginner question about setting up GraphQL. I'm struggling to find the right way to setup resolvers for my schema the most efficient way.
  Say in my schema I have a User type. Some field are resolved in one backend api, others in another.</p>
  <pre><code>type User {
     name: String
     address: String
     dateOfBirth: String
     department: String
     function: String
     manager: String
  }
  </code></pre>
  <p>name, address and dateOfBirth are from a basic administration, the other fields are from an organisation database.
  Suppose this is my resolver:</p>
  <pre><code>Query {
    User(parent, args, ctx) {
      return {
         name: '....',
         address: '...',
         dateOfBirth: '.....'
      }
    }
  } 
  </code></pre>
  <p>And resolvers for the specific subfields:</p>
  <pre><code>User {
     department(parent, args, ctx) {
     }
     function(parent, args, ctx) {
     }
     manager(parent, args, ctx) {
     }
  }
  </code></pre>
  <p>This would result in 4 requests if the user requested all fields. The last three request could have been 1 request to get all fields in one go. I would of course like that to be 2 requests: one for the base information and one for the organisation API. That would perhaps lead to this schema:</p>
  <pre><code>type User {
     name: String
     address: String
     dateOfBirth: String
     organisation: Organisation
  } 
  type Organisation {
     department: String
     function: String
     manager: String
  }
  </code></pre>
  <p>and my resolvers for the subfield:</p>
  <pre><code>User {
     organisation {
        return {
           department: '...',
           function: '...'
           manager: '...'
        }
     }
  } 
  </code></pre>
  <p>Now the request to the Organisation API gets requested only once. However, the schema looks weird: those fields should be part of a sub-object. And if we e.g. were to move the manager data to it's own API, the schema would break if we move it out of the sub-object Organisation.
  I tried solving this with a dataloader, but after trying some code examples, I think dataloader is more about the n+1 problem, revolving around keys of the same object type, than batching different fields.
  So, what would be the right way to go about this?</p>