mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
38 lines
2.1 KiB
JavaScript
38 lines
2.1 KiB
JavaScript
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
||
|
|
||
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||
|
|
||
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||
|
|
||
|
import invariant from "../jsutils/invariant.mjs";
|
||
|
import isPromise from "../jsutils/isPromise.mjs";
|
||
|
import { parse } from "../language/parser.mjs";
|
||
|
import { execute } from "../execution/execute.mjs";
|
||
|
import { getIntrospectionQuery } from "./getIntrospectionQuery.mjs";
|
||
|
/**
|
||
|
* Build an IntrospectionQuery from a GraphQLSchema
|
||
|
*
|
||
|
* IntrospectionQuery is useful for utilities that care about type and field
|
||
|
* relationships, but do not need to traverse through those relationships.
|
||
|
*
|
||
|
* This is the inverse of buildClientSchema. The primary use case is outside
|
||
|
* of the server context, for instance when doing schema comparisons.
|
||
|
*/
|
||
|
|
||
|
export function introspectionFromSchema(schema, options) {
|
||
|
var optionsWithDefaults = _objectSpread({
|
||
|
directiveIsRepeatable: true,
|
||
|
schemaDescription: true
|
||
|
}, options);
|
||
|
|
||
|
var document = parse(getIntrospectionQuery(optionsWithDefaults));
|
||
|
var result = execute({
|
||
|
schema: schema,
|
||
|
document: document
|
||
|
});
|
||
|
|
||
|
/* istanbul ignore next */
|
||
|
!isPromise(result) && !result.errors && result.data || invariant(0);
|
||
|
return result.data;
|
||
|
}
|