1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.makeExecutableSchema = void 0;
|
4 | const graphql_1 = require("graphql");
|
5 | const utils_1 = require("@graphql-tools/utils");
|
6 | const addResolversToSchema_js_1 = require("./addResolversToSchema.js");
|
7 | const assertResolversPresent_js_1 = require("./assertResolversPresent.js");
|
8 | const merge_1 = require("@graphql-tools/merge");
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | function makeExecutableSchema({ typeDefs, resolvers = {}, resolverValidationOptions = {}, inheritResolversFromInterfaces = false, updateResolversInPlace = false, schemaExtensions, ...otherOptions }) {
|
53 |
|
54 | if (typeof resolverValidationOptions !== 'object') {
|
55 | throw new Error('Expected `resolverValidationOptions` to be an object');
|
56 | }
|
57 | if (!typeDefs) {
|
58 | throw new Error('Must provide typeDefs');
|
59 | }
|
60 | let schema;
|
61 | if ((0, graphql_1.isSchema)(typeDefs)) {
|
62 | schema = typeDefs;
|
63 | }
|
64 | else if (otherOptions === null || otherOptions === void 0 ? void 0 : otherOptions.commentDescriptions) {
|
65 | const mergedTypeDefs = (0, merge_1.mergeTypeDefs)(typeDefs, {
|
66 | ...otherOptions,
|
67 | commentDescriptions: true,
|
68 | });
|
69 | schema = (0, graphql_1.buildSchema)(mergedTypeDefs, otherOptions);
|
70 | }
|
71 | else {
|
72 | const mergedTypeDefs = (0, merge_1.mergeTypeDefs)(typeDefs, otherOptions);
|
73 | schema = (0, graphql_1.buildASTSchema)(mergedTypeDefs, otherOptions);
|
74 | }
|
75 |
|
76 | schema = (0, addResolversToSchema_js_1.addResolversToSchema)({
|
77 | schema,
|
78 | resolvers: (0, merge_1.mergeResolvers)(resolvers),
|
79 | resolverValidationOptions,
|
80 | inheritResolversFromInterfaces,
|
81 | updateResolversInPlace,
|
82 | });
|
83 | if (Object.keys(resolverValidationOptions).length > 0) {
|
84 | (0, assertResolversPresent_js_1.assertResolversPresent)(schema, resolverValidationOptions);
|
85 | }
|
86 | if (schemaExtensions) {
|
87 | schemaExtensions = (0, merge_1.mergeExtensions)((0, utils_1.asArray)(schemaExtensions));
|
88 | (0, merge_1.applyExtensions)(schema, schemaExtensions);
|
89 | }
|
90 | return schema;
|
91 | }
|
92 | exports.makeExecutableSchema = makeExecutableSchema;
|