1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var fs = require("fs");
|
4 | var path = require("path");
|
5 | exports.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 |
|
\ | No newline at end of file |