UNPKG

@cran/gql.koa

Version:

Cran/GraphQL Koa Server

27 lines (26 loc) 1.06 kB
"use strict"; /* eslint-disable @typescript-eslint/naming-convention */ Object.defineProperty(exports, "__esModule", { value: true }); exports.DynamicApolloServer = void 0; const ApolloServer_1 = require("./ApolloServer"); class DynamicApolloServer extends ApolloServer_1.ApolloServer { schemaFactory; derivedData = new WeakMap(); constructor({ schemaFactory, ...rest }) { super(rest); this.schemaFactory = schemaFactory; } async createGraphQLServerOptions(...args) { const options = await super.createGraphQLServerOptions.apply(this, args); if (this.schemaFactory) { const schema = await this.schemaFactory.apply(null, args); if (!this.derivedData.has(schema)) { this.derivedData.set(schema, this.constructor.prototype .generateSchemaDerivedData.call(this, schema)); } Object.assign(options, await this.derivedData.get(schema)); } return options; } } exports.DynamicApolloServer = DynamicApolloServer;