UNPKG

1.34 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.introspectionFromSchema = introspectionFromSchema;
7
8var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
9
10var _introspectionQuery = require("./introspectionQuery");
11
12var _execute = require("../execution/execute");
13
14var _parser = require("../language/parser");
15
16function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
18/**
19 * Copyright (c) 2015-present, Facebook, Inc.
20 *
21 * This source code is licensed under the MIT license found in the
22 * LICENSE file in the root directory of this source tree.
23 *
24 *
25 */
26
27/**
28 * Build an IntrospectionQuery from a GraphQLSchema
29 *
30 * IntrospectionQuery is useful for utilities that care about type and field
31 * relationships, but do not need to traverse through those relationships.
32 *
33 * This is the inverse of buildClientSchema. The primary use case is outside
34 * of the server context, for instance when doing schema comparisons.
35 */
36function introspectionFromSchema(schema, options) {
37 var queryAST = (0, _parser.parse)((0, _introspectionQuery.getIntrospectionQuery)(options));
38 var result = (0, _execute.execute)(schema, queryAST);
39 !(!result.then && !result.errors && result.data) ? (0, _invariant.default)(0) : void 0;
40 return result.data;
41}
\No newline at end of file