Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
graphId: this.engineServiceId,
...(graphVariant && { graphVariant }),
}
: undefined;
return gateway.load({ engine: engineConfig }).then(config => {
this.requestOptions.executor = config.executor;
return config.schema;
});
}
let constructedSchema;
if (schema) {
constructedSchema = schema;
} else if (modules) {
const { schema, errors } = buildServiceDefinition(modules);
if (errors && errors.length > 0) {
throw new Error(errors.map(error => error.message).join('\n\n'));
}
constructedSchema = schema!;
} else {
if (!typeDefs) {
throw Error(
'Apollo Server requires either an existing schema, modules or typeDefs',
);
}
const augmentedTypeDefs = Array.isArray(typeDefs) ? typeDefs : [typeDefs];
// We augment the typeDefs with the @cacheControl directive and associated
// scope enum, so makeExecutableSchema won't fail SDL validation
// Plugins will be instantiated if they aren't already, and this.plugins
// is populated accordingly.
this.ensurePluginInstantiation(this.config.plugins);
// TODO(AS3) Make it possible to disable introspection.
// TODO(AS3) Cache Control
// TODO(AS3) Global cache implementation config.
// TODO(AS3) Persisted Queries
// TODO(AS3) Apollo Graph Manager
if (! this.config.modules) {
throw new Error("TODO: No modules were specified.");
}
const { schema, errors } = buildServiceDefinition(this.config.modules);
if (errors && errors.length > 0) {
throw new Error(errors.map(error => error.message).join('\n\n'));
}
if (!schema) {
throw new Error("TODO: No schema.");
}
this.schemaDerivedData = this.generateSchemaDerivedData(schema);
}