graphql-gateway

Put a bunch of graphql services behind one schema

Usage no npm install needed!

<script type="module">
  import graphqlGateway from 'https://cdn.skypack.dev/graphql-gateway';
</script>

README

graphql-gateway

Update CI npm package npm downloads

Graphql Gateway is a lightweight tool for routing different parts of a graphql query to different graphql apis and merging them back into one.

Usage

See test for example, here are the basics:

const graphqlGateway = require("graphql-gateway");
const combinedQuery = "query FooQuery {}" // the query that will be split up by schema
const result = graphqlGateway([{
  schema: /*<schema-one>*/,
  // everything besides resolve gets passed right to graphql-mask
  resolve: function(query, variables) {
    // query is a string with the peice associated with schema one
    return /*<result-of-query-on-schema-one>*/;
  }
},{
  schema: /*<schema-two>*/,
  resolve: function(query, variables) {
    // query is a string with the peice associated with schema two
    return /*<result-of-query-on-schema-two>*/;
  }
}
], combinedQuery, optionalMergeResolvers);

See the documentation for the merge-resolver npm module for the optionalMergeResolvers.

Alternatives

This tool is really lightweight and useful when you control all the underlying APIs and don't need any join functionality. Some really cool alternatives have been popping up, and while I haven't done a full evaluation, I'd like to point them out.