UNPKG

1 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var graphql_1 = require("graphql");
4var SchemaFromString = /** @class */ (function () {
5 function SchemaFromString() {
6 }
7 SchemaFromString.prototype.canHandle = function (str) {
8 // XXX: is-valid-path or is-glob treat SDL as a valid path
9 // (`scalar Date` for example)
10 // this why checking the extension is fast enough
11 // and prevent from parsing the string in order to find out
12 // if the string is a SDL
13 if (/\.[a-z0-9]+$/i.test(str)) {
14 return false;
15 }
16 try {
17 graphql_1.parse(str);
18 return true;
19 }
20 catch (e) {
21 return false;
22 }
23 };
24 SchemaFromString.prototype.handle = function (str, config, schemaOptions) {
25 return graphql_1.parse(str);
26 };
27 return SchemaFromString;
28}());
29exports.SchemaFromString = SchemaFromString;
30//# sourceMappingURL=schema-from-string.js.map
\No newline at end of file