UNPKG

1.13 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var fs = require("fs");
4var path = require("path");
5exports.introspectionFromFile = function (file) {
6 console.log("Loading GraphQL Introspection from file: " + file + "...");
7 return new Promise(function (resolve, reject) {
8 var fullPath = path.isAbsolute(file) ? file : path.resolve(process.cwd(), file);
9 if (fs.existsSync(fullPath)) {
10 try {
11 var fileContent = fs.readFileSync(fullPath, 'utf8');
12 if (!fileContent) {
13 reject("Unable to read local introspection file: " + fullPath);
14 }
15 var introspection = JSON.parse(fileContent);
16 if (introspection.data) {
17 introspection = introspection.data;
18 }
19 resolve(introspection);
20 }
21 catch (e) {
22 reject(e);
23 }
24 }
25 else {
26 reject("Unable to locate local introspection file: " + fullPath);
27 }
28 });
29};
30//# sourceMappingURL=introspection-from-file.js.map
\No newline at end of file