title: Wrap multiple 3rd party GraphQL APIs in a single GraphQL endpoint
body: <p>Vendors like GitHub are beginning to provide their own GraphQL APIs as an alternative to the existing REST APIs. However many apps shouldn't talk to these APIs directly and instead talk to first-party servers that in turn speak to these APIs.</p>
  
  <p>With REST APIs it's trivial to proxy an entire third-party API from a single endpoint. But the existing GraphQL libraries all seem to need to know the full GraphQL schema in advance and there doesn't seem to be any way to specify queries or types to be defined at run time.</p>
  
  <p>The even bigger problem seems to be that the entire GraphQL query will be parsed in advance. In order to pass on a sub-query to a third-party API that GraphQL fragment would have to be preserved or reconstructed.</p>
  
  <p>Here's an example that doesn't work:</p>
  
  <pre><code>new gql.GraphQLObjectType({
    fields () {
      return {
        thirdPartyApiCall: {
          type: '???', // Type is actually defined upstream
          resolve () {
            // GraphQL sub-query is already parsed at this point
            return thirdPartyGraphQLApi(graphQLSubQueryGoesHere)
          }
        }
      }
    }
  })
  </code></pre>
  
  <p>I think part of the answer could be to use introspection queries to generate the <code>type</code> in this example dynamically, once, when the schema is loaded (though of course this means it won't reflect changes upstream unless it is re-generated frequently) but I'm at a complete loss as to how to get the original GraphQL sub-query to pass on to the third party.</p>
  
  <p>Is this currently solvable in GraphQL without writing a custom GraphQL parser/handler or does GraphQL currently not support this kind of delegation (i.e. wrapping 3rd party GraphQL APIs directly)?</p>