Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import path from 'path';
import { makeExecutableSchema } from 'graphql-tools';
import { fileLoader, mergeResolvers, mergeTypes } from 'merge-graphql-schemas';
const allTypes = fileLoader(path.join(__dirname, 'api/**/*.graphql'));
const allResolvers = fileLoader(path.join(__dirname, 'api/**/*.js'));
const schema = makeExecutableSchema({
typeDefs: mergeTypes(allTypes),
resolvers: mergeResolvers(allResolvers),
});
export default schema;
import path from "path";
import { makeExecutableSchema } from 'graphql-tools';
import { fileLoader, mergeTypes, mergeResolvers } from 'merge-graphql-schemas';
const typesArray = fileLoader(path.join(__dirname, '../types'), { recursive: true });
const resolversArray = fileLoader(path.join(__dirname, '../resolvers'));
const allTypes = mergeTypes(typesArray);
const allResolvers = mergeResolvers(resolversArray);
const schema = makeExecutableSchema({
typeDefs: allTypes,
resolvers: allResolvers
});
export default schema;
constructor (config) {
const typeDefs = mergeTypes(fileLoader(config.get('graphql.schema'), { recursive: true }))
const resolvers = mergeResolvers(fileLoader(config.get('graphql.resolvers')))
this.$schema = makeExecutableSchema({ typeDefs, resolvers })
this.$options = config.get('graphql.options') || {}
}
_loadResolversController () {
const middleware = []
ResolverManager.resolvers.forEach(resolver => {
this._resolvers.push(resolver.transform())
middleware.push(resolver.middlewares)
})
this._loadGlobalMiddlewares()
this._loadNamedMiddlewares(middleware)
this.$resolvers = mergeResolvers(this._resolvers)
}
getSchema(): GraphQLModule {
return {
typeDefs: mergeTypes(this.typeDefs, { all: true }),
resolvers: mergeResolvers(this.resolvers),
};
}