UNPKG

1.03 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var isValidPath = require("is-valid-path");
4var graphql_1 = require("graphql");
5var graphql_tools_1 = require("graphql-tools");
6var SchemaFromString = /** @class */ (function () {
7 function SchemaFromString() {
8 }
9 SchemaFromString.prototype.canHandle = function (str) {
10 if (isValidPath(str)) {
11 return false;
12 }
13 try {
14 graphql_1.parse(str);
15 return true;
16 }
17 catch (e) {
18 return false;
19 }
20 };
21 SchemaFromString.prototype.handle = function (str, config, schemaOptions) {
22 return graphql_tools_1.makeExecutableSchema({
23 typeDefs: [str],
24 allowUndefinedInResolve: true,
25 resolvers: {},
26 resolverValidationOptions: { requireResolversForResolveType: false }
27 });
28 };
29 return SchemaFromString;
30}());
31exports.SchemaFromString = SchemaFromString;
32//# sourceMappingURL=schema-from-string.js.map
\No newline at end of file