UNPKG

@graphql-tools/merge

Version:

A set of utils for faster development of GraphQL tools

15 lines (14 loc) 532 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mergeNamedTypeArray = mergeNamedTypeArray; const utils_1 = require("@graphql-tools/utils"); function alreadyExists(arr, other) { return !!arr.find(i => i.name.value === other.name.value); } function mergeNamedTypeArray(first = [], second = [], config = {}) { const result = [...second, ...first.filter(d => !alreadyExists(second, d))]; if (config && config.sort) { result.sort(utils_1.compareNodes); } return result; }