1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.removeNonNullWrapper = exports.getBaseType = exports.isWrapperType = exports.mergeOutputs = void 0;
|
4 | const graphql_1 = require("graphql");
|
5 | function mergeOutputs(content) {
|
6 | const result = { content: '', prepend: [], append: [] };
|
7 | if (Array.isArray(content)) {
|
8 | content.forEach(item => {
|
9 | if (typeof item === 'string') {
|
10 | result.content += item;
|
11 | }
|
12 | else {
|
13 | result.content += item.content;
|
14 | result.prepend.push(...(item.prepend || []));
|
15 | result.append.push(...(item.append || []));
|
16 | }
|
17 | });
|
18 | }
|
19 | return [...result.prepend, result.content, ...result.append].join('\n');
|
20 | }
|
21 | exports.mergeOutputs = mergeOutputs;
|
22 | function isWrapperType(t) {
|
23 | return (0, graphql_1.isListType)(t) || (0, graphql_1.isNonNullType)(t);
|
24 | }
|
25 | exports.isWrapperType = isWrapperType;
|
26 | function getBaseType(type) {
|
27 | if (isWrapperType(type)) {
|
28 | return getBaseType(type.ofType);
|
29 | }
|
30 | return type;
|
31 | }
|
32 | exports.getBaseType = getBaseType;
|
33 | function removeNonNullWrapper(type) {
|
34 | return (0, graphql_1.isNonNullType)(type) ? type.ofType : type;
|
35 | }
|
36 | exports.removeNonNullWrapper = removeNonNullWrapper;
|