UNPKG

simple-graphql

Version:

The simple way to generates GraphQL schemas and Sequelize models from your models definition.

25 lines 979 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const lodash_1 = __importDefault(require("lodash")); function default_1(args) { const dbModel = this; const { info, path } = args; if (!info) { return false; } const fragments = info.fragments || {}; let selections = []; (info.fieldNodes || []).forEach((node) => { var _a; selections = lodash_1.default.union(selections, dbModel.parseSelections(fragments, (_a = node.selectionSet) === null || _a === void 0 ? void 0 : _a.selections)); }); path.split('.').forEach((p) => { selections = lodash_1.default.flatten(selections.filter((s) => s.name === p).map((t) => t.selections || [])); }); return selections.length > 0; } exports.default = default_1; //# sourceMappingURL=hasSelection.js.map