Initial implementation at plugins

This commit is contained in:
gaba
2017-03-20 07:36:06 -07:00
parent 2ee6335328
commit 258fd8b25a
11 changed files with 334 additions and 23 deletions
+20 -2
View File
@@ -4,8 +4,26 @@
const fs = require('fs');
const path = require('path');
const {mergeStrings} = require('gql-merge');
const debug = require('debug')('talk:graph:typeDefs');
const plugins = require('../plugins');
// Load the typeDefs from the graphql file.
const typeDefs = fs.readFileSync(path.join(__dirname, 'typeDefs.graphql'), 'utf8');
/**
* Plugin support requires us to merge the type definitions from the loaded
* graphql tags, this gives us the ability to extend any portion of the
* available graph.
*/
const typeDefs = mergeStrings([
// Load the core graph definitions from the filesystem.
fs.readFileSync(path.join(__dirname, 'typeDefs.graphql'), 'utf8'),
// Load the plugin definitions from the manager.
...plugins.get('server', 'typeDefs').map(({plugin, typeDefs}) => {
debug(`added plugin '${plugin.name}'`);
return typeDefs;
})
]);
module.exports = typeDefs;