makeExecutableSchema({ typeDefs, resolvers: {
addErrorLoggingToSchema(schema, { log: e => { if (app.logFormat === 'text') return console.error(e.message); if (app.logFormat === 'json') return console.error( JSON.stringify({ message: e.message, error: e, stack: e.stack, type: 'Error' }) ); } });
visitFieldDefinition(field) { if (!field.permissionsConfig) { // eslint-disable-next-line no-param-reassign field.permissionsConfig = { all: [], any: [], }; } field.permissionsConfig.all.push(...(this.args.all || [])); field.permissionsConfig.any.push(...(this.args.any || [])); this.wrapField(field); }
Promise.map(config.graphql.remotes, (async (uri: string) => { logger.info(`loading remote schema from { ${uri} }`); const fetcher = createApolloFetch({ uri }); const schema = makeRemoteExecutableSchema({ schema: await introspectSchema(fetcher), fetcher, }); return schema; }))
visitFieldDefinition(field) { if (!field.isAuthenticatedConfig) { field.isAuthenticatedConfig = {}; // eslint-disable-line no-param-reassign } field.isAuthenticatedConfig.roles = this.args.roles; // eslint-disable-line no-param-reassign this.wrapField(field); }
private mergeSchemas(allSchemas): GraphQLSchema { return mergeSchemas({ schemas: allSchemas }); }
visitObject(type) { this.ensureFieldsWrapped(type); type._requiredAuthRole = this.args.role; }
//async function due to the async nature of grabbing all of our introspect schemas (async function () { try { //promise.all to grab all remote schemas at the same time, we do not care what order they come back but rather just when they finish allSchemas = await Promise.all(endpoints.map(ep => getIntrospectSchema(ep))); //create function for /graphql endpoint and merge all the schemas app.use('/graphql', bodyParser.json(), graphqlExpress({ schema: mergeSchemas({ schemas: allSchemas }) })); //start up a graphql endpoint for our main server app.listen(PORT, () => console.log('GraphQL API listening on port:' + PORT)); } catch (error) { console.log('ERROR: Failed to grab introspection queries', error); } })();
makeExecutableSchema( this.getConfig('configureSchema', identity)({ typeDefs: this.typeDefs, resolvers: this.applyResolversMiddlewares(this.resolvers), logger: { log: err => { this.emit('error', err); }, }, allowUndefinedInResolve: false, inheritResolversFromInterfaces: true, schemaDirectives: this.directives, }), )
visitFieldDefinition(field, details) { this.ensureFieldsWrapped(details.objectType); field._requiredAuthRole = this.args.role; }
visitFieldDefinition(field) { if (!field.permissionsConfig) { // eslint-disable-next-line no-param-reassign field.permissionsConfig = { all: [], any: [], }; } field.permissionsConfig.all.push(...(this.args.all || [])); field.permissionsConfig.any.push(...(this.args.any || [])); this.wrapField(field); }
visitFieldDefinition(field) { if (!field.isAuthenticatedConfig) { field.isAuthenticatedConfig = {}; // eslint-disable-line no-param-reassign } field.isAuthenticatedConfig.roles = this.args.roles; // eslint-disable-line no-param-reassign this.wrapField(field); }
visitFieldDefinition(field, details) { this.ensureFieldsWrapped(details.objectType); field._requiredAuthRole = this.args.role; }
visitObject(type) { this.ensureFieldsWrapped(type); type._requiredAuthRole = this.args.role; }
//async function due to the async nature of grabbing all of our introspect schemas (async function () { try { //promise.all to grab all remote schemas at the same time, we do not care what order they come back but rather just when they finish allSchemas = await Promise.all(endpoints.map(ep => getIntrospectSchema(ep))); //create function for /graphql endpoint and merge all the schemas app.use('/graphql', bodyParser.json(), graphqlExpress({ schema: mergeSchemas({ schemas: allSchemas }) })); //start up a graphql endpoint for our main server app.listen(PORT, () => console.log('GraphQL API listening on port:' + PORT)); } catch (error) { console.log('ERROR: Failed to grab introspection queries', error); } })();