Skip to content

Instantly share code, notes, and snippets.

@flesch
Created December 15, 2017 17:07
Show Gist options
  • Save flesch/35b19abf103aa08c16fad222e68e90c4 to your computer and use it in GitHub Desktop.
Save flesch/35b19abf103aa08c16fad222e68e90c4 to your computer and use it in GitHub Desktop.
const { buildSchema } = require('graphql');
const glob = require('glob-promise');
const { readFile } = require('fs-extra');
const { join } = require('path');
async function stitchSchema(dir) {
const files = await glob(dir);
const contents = await Promise.all(files.map(file => readFile(file, 'utf8')));
return buildSchema(contents.join('\n\n'));
}
module.exports = { stitchSchema };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment