1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.AbstractGraphQLDriver = void 0;
|
4 | const tslib_1 = require("tslib");
|
5 | const common_1 = require("@nestjs/common");
|
6 | const core_1 = require("@nestjs/core");
|
7 | const graphql_factory_1 = require("../graphql.factory");
|
8 | const utils_1 = require("../utils");
|
9 | class AbstractGraphQLDriver {
|
10 | async mergeDefaultOptions(options, defaults = {
|
11 | path: '/graphql',
|
12 | fieldResolverEnhancers: [],
|
13 | }) {
|
14 | const clonedOptions = {
|
15 | ...defaults,
|
16 | ...options,
|
17 | };
|
18 | clonedOptions.path =
|
19 | this.getNormalizedPath(clonedOptions);
|
20 | return clonedOptions;
|
21 | }
|
22 | generateSchema(options) {
|
23 | return this.graphQlFactory.generateSchema(options);
|
24 | }
|
25 | subscriptionWithFilter(instanceRef, filterFn, createSubscribeContext) {
|
26 | return createSubscribeContext();
|
27 | }
|
28 | getNormalizedPath(options) {
|
29 | const prefix = this.applicationConfig?.getGlobalPrefix() ?? '';
|
30 | const useGlobalPrefix = prefix && options.useGlobalPrefix;
|
31 | const gqlOptionsPath = (0, utils_1.normalizeRoutePath)(options.path);
|
32 | return useGlobalPrefix
|
33 | ? (0, utils_1.normalizeRoutePath)(prefix) + gqlOptionsPath
|
34 | : gqlOptionsPath;
|
35 | }
|
36 | }
|
37 | exports.AbstractGraphQLDriver = AbstractGraphQLDriver;
|
38 | tslib_1.__decorate([
|
39 | (0, common_1.Inject)(),
|
40 | tslib_1.__metadata("design:type", core_1.HttpAdapterHost)
|
41 | ], AbstractGraphQLDriver.prototype, "httpAdapterHost", void 0);
|
42 | tslib_1.__decorate([
|
43 | (0, common_1.Inject)(),
|
44 | tslib_1.__metadata("design:type", core_1.ApplicationConfig)
|
45 | ], AbstractGraphQLDriver.prototype, "applicationConfig", void 0);
|
46 | tslib_1.__decorate([
|
47 | (0, common_1.Inject)(),
|
48 | tslib_1.__metadata("design:type", graphql_factory_1.GraphQLFactory)
|
49 | ], AbstractGraphQLDriver.prototype, "graphQlFactory", void 0);
|