From ee06bdf63d963492f043792bd2a9d46acbc232c9 Mon Sep 17 00:00:00 2001 From: izzy lyseggen Date: Tue, 11 Aug 2020 14:39:06 +0100 Subject: [PATCH] feat(directives): add @hasScope to schema --- modules/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/index.js b/modules/index.js index 7b612b5f7..bdf437dc4 100644 --- a/modules/index.js +++ b/modules/index.js @@ -7,6 +7,7 @@ const values = require( 'lodash.values' ) const merge = require( 'lodash.merge' ) const debug = require( 'debug' )( 'speckle:modules' ) const { scalarResolvers, scalarSchemas } = require( './core/graph/scalars' ) +const { HasScopeDirective } = require( './core/graph/directives/hasScope' ) exports.init = async ( app ) => { let dirs = fs.readdirSync( `${appRoot}/modules` ) @@ -33,6 +34,7 @@ exports.graph = ( ) => { // Base query and mutation to allow for type extension by modules. let typeDefs = [ ` ${scalarSchemas} + directive @hasScope(scope: String!) on FIELD_DEFINITION type Query { """ @@ -71,6 +73,8 @@ exports.graph = ( ) => { if ( fs.existsSync( path.join( fullPath, 'graph', 'resolvers' ) ) ) { resolverObjs = [ ...resolverObjs, ...values( autoload( path.join( fullPath, 'graph', 'resolvers' ) ) ) ] } + + // should load directives here in similar way } ) let resolvers = { ...scalarResolvers } @@ -78,5 +82,10 @@ exports.graph = ( ) => { merge( resolvers, o ) } ) - return { resolvers, typeDefs } + // register directives temp + let schemaDirectives = { + hasScope: HasScopeDirective + } + + return { resolvers, typeDefs, schemaDirectives } }