1 | Object.defineProperty(exports, "__esModule", { value: true });
|
2 | var graphql_1 = require("graphql");
|
3 | var _1 = require(".");
|
4 | function buildSchemaFromTypeDefinitions(typeDefinitions, parseOptions) {
|
5 |
|
6 | var myDefinitions = typeDefinitions;
|
7 | var astDocument;
|
8 | if (isDocumentNode(typeDefinitions)) {
|
9 | astDocument = typeDefinitions;
|
10 | }
|
11 | else if (typeof myDefinitions !== 'string') {
|
12 | if (!Array.isArray(myDefinitions)) {
|
13 | var type = typeof myDefinitions;
|
14 | throw new _1.SchemaError("typeDefs must be a string, array or schema AST, got " + type);
|
15 | }
|
16 | myDefinitions = _1.concatenateTypeDefs(myDefinitions);
|
17 | }
|
18 | if (typeof myDefinitions === 'string') {
|
19 | astDocument = graphql_1.parse(myDefinitions, parseOptions);
|
20 | }
|
21 | var backcompatOptions = { commentDescriptions: true };
|
22 |
|
23 | var schema = graphql_1.buildASTSchema(astDocument, backcompatOptions);
|
24 | var extensionsAst = _1.extractExtensionDefinitions(astDocument);
|
25 | if (extensionsAst.definitions.length > 0) {
|
26 |
|
27 | schema = graphql_1.extendSchema(schema, extensionsAst, backcompatOptions);
|
28 | }
|
29 | return schema;
|
30 | }
|
31 | function isDocumentNode(typeDefinitions) {
|
32 | return typeDefinitions.kind !== undefined;
|
33 | }
|
34 | exports.default = buildSchemaFromTypeDefinitions;
|
35 |
|
\ | No newline at end of file |