graphqldoc
Version:
Generate GraphQL docs from schema.
24 lines (23 loc) • 1.33 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const utility_1 = require("../utility");
const introspectionParser_1 = require("./introspectionParser");
const path_1 = require("path");
const fs_1 = require("../utility/fs");
const graphql_1 = require("graphql");
exports.idlSchemaLoader = function (options) {
return __awaiter(this, void 0, void 0, function* () {
const schemaPath = path_1.resolve(options.schemaFile);
const idl = yield fs_1.readFile(schemaPath, 'utf8');
const introspection = yield graphql_1.execute(graphql_1.buildSchema(idl), graphql_1.parse(utility_1.query));
return introspectionParser_1.getSchemaFromIntrospection(introspection);
});
};