1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var isValidPath = require("is-valid-path");
|
4 | var graphql_1 = require("graphql");
|
5 | var graphql_tools_1 = require("graphql-tools");
|
6 | var SchemaFromString = (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 | }());
|
31 | exports.SchemaFromString = SchemaFromString;
|
32 |
|
\ | No newline at end of file |