UNPKG

@apollo/core-schema

Version:
24 lines 1.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.byKind = exports.byName = exports.hasName = exports.toDefinitionKind = exports.isAst = void 0; const graphql_1 = require("graphql"); const each_1 = require("./each"); function isAst(obj, ...kinds) { if (!kinds.length) return typeof (obj === null || obj === void 0 ? void 0 : obj.kind) === 'string'; return kinds.indexOf(obj === null || obj === void 0 ? void 0 : obj.kind) !== -1; } exports.isAst = isAst; function toDefinitionKind(kind) { if (kind.endsWith('Definition')) return kind; if (kind.endsWith('Extension')) return kind.substring(0, kind.length - 'Extension'.length) + 'Definition'; return undefined; } exports.toDefinitionKind = toDefinitionKind; const hasName = (o) => o && isAst(o.name, graphql_1.Kind.NAME); exports.hasName = hasName; exports.byName = (0, each_1.groupBy)((field) => { var _a; return (_a = field.name) === null || _a === void 0 ? void 0 : _a.value; }); exports.byKind = (0, each_1.groupBy)((node) => node.kind); //# sourceMappingURL=is.js.map