@graphql-tools/merge 6.2.17 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es5/index.d.ts +0 -1
- package/es5/index.js +7 -525
- package/es5/index.mjs +6 -517
- package/es5/package.json +2 -3
- package/es5/typedefs-mergers/index.d.ts +0 -1
- package/es5/typedefs-mergers/merge-nodes.d.ts +2 -4
- package/index.d.ts +0 -1
- package/index.js +13 -355
- package/index.mjs +11 -346
- package/package.json +2 -3
- package/typedefs-mergers/index.d.ts +0 -1
- package/typedefs-mergers/merge-nodes.d.ts +2 -4
- package/es5/merge-schemas.d.ts +0 -34
- package/es5/typedefs-mergers/comments.d.ts +0 -11
- package/merge-schemas.d.ts +0 -34
- package/typedefs-mergers/comments.d.ts +0 -11
package/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { mergeDeep, isSome, compareNodes, isNotEqual,
|
|
2
|
-
import {
|
|
3
|
-
import { addResolversToSchema } from '@graphql-tools/schema';
|
|
1
|
+
import { mergeDeep, isSome, compareNodes, isNotEqual, collectComment, resetComments, printWithComments, getDocumentNodeFromSchema, isDocumentNode } from '@graphql-tools/utils';
|
|
2
|
+
import { print, Source, Kind, isSchema, parse, isDefinitionNode, isScalarType, isSpecifiedScalarType, isIntrospectionType, isObjectType, isInterfaceType, isInputObjectType, isUnionType, isEnumType } from 'graphql';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Deep merges multiple resolver definition objects into a single definition.
|
|
@@ -82,289 +81,6 @@ function deduplicateArguments(args) {
|
|
|
82
81
|
}, []);
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
const MAX_LINE_LENGTH = 80;
|
|
86
|
-
let commentsRegistry = {};
|
|
87
|
-
function resetComments() {
|
|
88
|
-
commentsRegistry = {};
|
|
89
|
-
}
|
|
90
|
-
function collectComment(node) {
|
|
91
|
-
var _a;
|
|
92
|
-
const entityName = (_a = node.name) === null || _a === void 0 ? void 0 : _a.value;
|
|
93
|
-
if (entityName == null) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
pushComment(node, entityName);
|
|
97
|
-
switch (node.kind) {
|
|
98
|
-
case 'EnumTypeDefinition':
|
|
99
|
-
if (node.values) {
|
|
100
|
-
for (const value of node.values) {
|
|
101
|
-
pushComment(value, entityName, value.name.value);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
break;
|
|
105
|
-
case 'ObjectTypeDefinition':
|
|
106
|
-
case 'InputObjectTypeDefinition':
|
|
107
|
-
case 'InterfaceTypeDefinition':
|
|
108
|
-
if (node.fields) {
|
|
109
|
-
for (const field of node.fields) {
|
|
110
|
-
pushComment(field, entityName, field.name.value);
|
|
111
|
-
if (isFieldDefinitionNode(field) && field.arguments) {
|
|
112
|
-
for (const arg of field.arguments) {
|
|
113
|
-
pushComment(arg, entityName, field.name.value, arg.name.value);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
function pushComment(node, entity, field, argument) {
|
|
122
|
-
const comment = getDescription(node, { commentDescriptions: true });
|
|
123
|
-
if (typeof comment !== 'string' || comment.length === 0) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
const keys = [entity];
|
|
127
|
-
if (field) {
|
|
128
|
-
keys.push(field);
|
|
129
|
-
if (argument) {
|
|
130
|
-
keys.push(argument);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
const path = keys.join('.');
|
|
134
|
-
if (!commentsRegistry[path]) {
|
|
135
|
-
commentsRegistry[path] = [];
|
|
136
|
-
}
|
|
137
|
-
commentsRegistry[path].push(comment);
|
|
138
|
-
}
|
|
139
|
-
function printComment(comment) {
|
|
140
|
-
return '\n# ' + comment.replace(/\n/g, '\n# ');
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Copyright (c) 2015-present, Facebook, Inc.
|
|
144
|
-
*
|
|
145
|
-
* This source code is licensed under the MIT license found in the
|
|
146
|
-
* LICENSE file in the root directory of this source tree.
|
|
147
|
-
*/
|
|
148
|
-
/**
|
|
149
|
-
* NOTE: ==> This file has been modified just to add comments to the printed AST
|
|
150
|
-
* This is a temp measure, we will move to using the original non modified printer.js ASAP.
|
|
151
|
-
*/
|
|
152
|
-
// import { visit, VisitFn } from 'graphql';
|
|
153
|
-
/**
|
|
154
|
-
* Given maybeArray, print an empty string if it is null or empty, otherwise
|
|
155
|
-
* print all items together separated by separator if provided
|
|
156
|
-
*/
|
|
157
|
-
function join(maybeArray, separator) {
|
|
158
|
-
return maybeArray ? maybeArray.filter(x => x).join(separator || '') : '';
|
|
159
|
-
}
|
|
160
|
-
function hasMultilineItems(maybeArray) {
|
|
161
|
-
var _a;
|
|
162
|
-
return (_a = maybeArray === null || maybeArray === void 0 ? void 0 : maybeArray.some(str => str.includes('\n'))) !== null && _a !== void 0 ? _a : false;
|
|
163
|
-
}
|
|
164
|
-
function addDescription(cb) {
|
|
165
|
-
return (node, _key, _parent, path, ancestors) => {
|
|
166
|
-
var _a;
|
|
167
|
-
const keys = [];
|
|
168
|
-
const parent = path.reduce((prev, key) => {
|
|
169
|
-
if (['fields', 'arguments', 'values'].includes(key) && prev.name) {
|
|
170
|
-
keys.push(prev.name.value);
|
|
171
|
-
}
|
|
172
|
-
return prev[key];
|
|
173
|
-
}, ancestors[0]);
|
|
174
|
-
const key = [...keys, (_a = parent === null || parent === void 0 ? void 0 : parent.name) === null || _a === void 0 ? void 0 : _a.value].filter(Boolean).join('.');
|
|
175
|
-
const items = [];
|
|
176
|
-
if (node.kind.includes('Definition') && commentsRegistry[key]) {
|
|
177
|
-
items.push(...commentsRegistry[key]);
|
|
178
|
-
}
|
|
179
|
-
return join([...items.map(printComment), node.description, cb(node)], '\n');
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
function indent(maybeString) {
|
|
183
|
-
return maybeString && ` ${maybeString.replace(/\n/g, '\n ')}`;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Given array, print each item on its own line, wrapped in an
|
|
187
|
-
* indented "{ }" block.
|
|
188
|
-
*/
|
|
189
|
-
function block(array) {
|
|
190
|
-
return array && array.length !== 0 ? `{\n${indent(join(array, '\n'))}\n}` : '';
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* If maybeString is not null or empty, then wrap with start and end, otherwise
|
|
194
|
-
* print an empty string.
|
|
195
|
-
*/
|
|
196
|
-
function wrap(start, maybeString, end) {
|
|
197
|
-
return maybeString ? start + maybeString + (end || '') : '';
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Print a block string in the indented block form by adding a leading and
|
|
201
|
-
* trailing blank line. However, if a block string starts with whitespace and is
|
|
202
|
-
* a single-line, adding a leading blank line would strip that whitespace.
|
|
203
|
-
*/
|
|
204
|
-
function printBlockString(value, isDescription = false) {
|
|
205
|
-
const escaped = value.replace(/"""/g, '\\"""');
|
|
206
|
-
return (value[0] === ' ' || value[0] === '\t') && value.indexOf('\n') === -1
|
|
207
|
-
? `"""${escaped.replace(/"$/, '"\n')}"""`
|
|
208
|
-
: `"""\n${isDescription ? escaped : indent(escaped)}\n"""`;
|
|
209
|
-
}
|
|
210
|
-
const printDocASTReducer = {
|
|
211
|
-
Name: { leave: node => node.value },
|
|
212
|
-
Variable: { leave: node => '$' + node.name },
|
|
213
|
-
// Document
|
|
214
|
-
Document: {
|
|
215
|
-
leave: node => join(node.definitions, '\n\n'),
|
|
216
|
-
},
|
|
217
|
-
OperationDefinition: {
|
|
218
|
-
leave: node => {
|
|
219
|
-
const varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');
|
|
220
|
-
const prefix = join([node.operation, join([node.name, varDefs]), join(node.directives, ' ')], ' ');
|
|
221
|
-
// the query short form.
|
|
222
|
-
return prefix + ' ' + node.selectionSet;
|
|
223
|
-
},
|
|
224
|
-
},
|
|
225
|
-
VariableDefinition: {
|
|
226
|
-
leave: ({ variable, type, defaultValue, directives }) => variable + ': ' + type + wrap(' = ', defaultValue) + wrap(' ', join(directives, ' ')),
|
|
227
|
-
},
|
|
228
|
-
SelectionSet: { leave: ({ selections }) => block(selections) },
|
|
229
|
-
Field: {
|
|
230
|
-
leave({ alias, name, arguments: args, directives, selectionSet }) {
|
|
231
|
-
const prefix = wrap('', alias, ': ') + name;
|
|
232
|
-
let argsLine = prefix + wrap('(', join(args, ', '), ')');
|
|
233
|
-
if (argsLine.length > MAX_LINE_LENGTH) {
|
|
234
|
-
argsLine = prefix + wrap('(\n', indent(join(args, '\n')), '\n)');
|
|
235
|
-
}
|
|
236
|
-
return join([argsLine, join(directives, ' '), selectionSet], ' ');
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
Argument: { leave: ({ name, value }) => name + ': ' + value },
|
|
240
|
-
// Fragments
|
|
241
|
-
FragmentSpread: {
|
|
242
|
-
leave: ({ name, directives }) => '...' + name + wrap(' ', join(directives, ' ')),
|
|
243
|
-
},
|
|
244
|
-
InlineFragment: {
|
|
245
|
-
leave: ({ typeCondition, directives, selectionSet }) => join(['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet], ' '),
|
|
246
|
-
},
|
|
247
|
-
FragmentDefinition: {
|
|
248
|
-
leave: ({ name, typeCondition, variableDefinitions, directives, selectionSet }) =>
|
|
249
|
-
// Note: fragment variable definitions are experimental and may be changed
|
|
250
|
-
// or removed in the future.
|
|
251
|
-
`fragment ${name}${wrap('(', join(variableDefinitions, ', '), ')')} ` +
|
|
252
|
-
`on ${typeCondition} ${wrap('', join(directives, ' '), ' ')}` +
|
|
253
|
-
selectionSet,
|
|
254
|
-
},
|
|
255
|
-
// Value
|
|
256
|
-
IntValue: { leave: ({ value }) => value },
|
|
257
|
-
FloatValue: { leave: ({ value }) => value },
|
|
258
|
-
StringValue: {
|
|
259
|
-
leave: ({ value, block: isBlockString }) => (isBlockString ? printBlockString(value) : JSON.stringify(value)),
|
|
260
|
-
},
|
|
261
|
-
BooleanValue: { leave: ({ value }) => (value ? 'true' : 'false') },
|
|
262
|
-
NullValue: { leave: () => 'null' },
|
|
263
|
-
EnumValue: { leave: ({ value }) => value },
|
|
264
|
-
ListValue: { leave: ({ values }) => '[' + join(values, ', ') + ']' },
|
|
265
|
-
ObjectValue: { leave: ({ fields }) => '{' + join(fields, ', ') + '}' },
|
|
266
|
-
ObjectField: { leave: ({ name, value }) => name + ': ' + value },
|
|
267
|
-
// Directive
|
|
268
|
-
Directive: {
|
|
269
|
-
leave: ({ name, arguments: args }) => '@' + name + wrap('(', join(args, ', '), ')'),
|
|
270
|
-
},
|
|
271
|
-
// Type
|
|
272
|
-
NamedType: { leave: ({ name }) => name },
|
|
273
|
-
ListType: { leave: ({ type }) => '[' + type + ']' },
|
|
274
|
-
NonNullType: { leave: ({ type }) => type + '!' },
|
|
275
|
-
// Type System Definitions
|
|
276
|
-
SchemaDefinition: {
|
|
277
|
-
leave: ({ description, directives, operationTypes }) => wrap('', description, '\n') + join(['schema', join(directives, ' '), block(operationTypes)], ' '),
|
|
278
|
-
},
|
|
279
|
-
OperationTypeDefinition: {
|
|
280
|
-
leave: ({ operation, type }) => operation + ': ' + type,
|
|
281
|
-
},
|
|
282
|
-
ScalarTypeDefinition: {
|
|
283
|
-
leave: ({ description, name, directives }) => wrap('', description, '\n') + join(['scalar', name, join(directives, ' ')], ' '),
|
|
284
|
-
},
|
|
285
|
-
ObjectTypeDefinition: {
|
|
286
|
-
leave: ({ description, name, interfaces, directives, fields }) => wrap('', description, '\n') +
|
|
287
|
-
join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '),
|
|
288
|
-
},
|
|
289
|
-
FieldDefinition: {
|
|
290
|
-
leave: ({ description, name, arguments: args, type, directives }) => wrap('', description, '\n') +
|
|
291
|
-
name +
|
|
292
|
-
(hasMultilineItems(args)
|
|
293
|
-
? wrap('(\n', indent(join(args, '\n')), '\n)')
|
|
294
|
-
: wrap('(', join(args, ', '), ')')) +
|
|
295
|
-
': ' +
|
|
296
|
-
type +
|
|
297
|
-
wrap(' ', join(directives, ' ')),
|
|
298
|
-
},
|
|
299
|
-
InputValueDefinition: {
|
|
300
|
-
leave: ({ description, name, type, defaultValue, directives }) => wrap('', description, '\n') + join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' '),
|
|
301
|
-
},
|
|
302
|
-
InterfaceTypeDefinition: {
|
|
303
|
-
leave: ({ description, name, interfaces, directives, fields }) => wrap('', description, '\n') +
|
|
304
|
-
join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '),
|
|
305
|
-
},
|
|
306
|
-
UnionTypeDefinition: {
|
|
307
|
-
leave: ({ description, name, directives, types }) => wrap('', description, '\n') + join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' '),
|
|
308
|
-
},
|
|
309
|
-
EnumTypeDefinition: {
|
|
310
|
-
leave: ({ description, name, directives, values }) => wrap('', description, '\n') + join(['enum', name, join(directives, ' '), block(values)], ' '),
|
|
311
|
-
},
|
|
312
|
-
EnumValueDefinition: {
|
|
313
|
-
leave: ({ description, name, directives }) => wrap('', description, '\n') + join([name, join(directives, ' ')], ' '),
|
|
314
|
-
},
|
|
315
|
-
InputObjectTypeDefinition: {
|
|
316
|
-
leave: ({ description, name, directives, fields }) => wrap('', description, '\n') + join(['input', name, join(directives, ' '), block(fields)], ' '),
|
|
317
|
-
},
|
|
318
|
-
DirectiveDefinition: {
|
|
319
|
-
leave: ({ description, name, arguments: args, repeatable, locations }) => wrap('', description, '\n') +
|
|
320
|
-
'directive @' +
|
|
321
|
-
name +
|
|
322
|
-
(hasMultilineItems(args)
|
|
323
|
-
? wrap('(\n', indent(join(args, '\n')), '\n)')
|
|
324
|
-
: wrap('(', join(args, ', '), ')')) +
|
|
325
|
-
(repeatable ? ' repeatable' : '') +
|
|
326
|
-
' on ' +
|
|
327
|
-
join(locations, ' | '),
|
|
328
|
-
},
|
|
329
|
-
SchemaExtension: {
|
|
330
|
-
leave: ({ directives, operationTypes }) => join(['extend schema', join(directives, ' '), block(operationTypes)], ' '),
|
|
331
|
-
},
|
|
332
|
-
ScalarTypeExtension: {
|
|
333
|
-
leave: ({ name, directives }) => join(['extend scalar', name, join(directives, ' ')], ' '),
|
|
334
|
-
},
|
|
335
|
-
ObjectTypeExtension: {
|
|
336
|
-
leave: ({ name, interfaces, directives, fields }) => join(['extend type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '),
|
|
337
|
-
},
|
|
338
|
-
InterfaceTypeExtension: {
|
|
339
|
-
leave: ({ name, interfaces, directives, fields }) => join(['extend interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '),
|
|
340
|
-
},
|
|
341
|
-
UnionTypeExtension: {
|
|
342
|
-
leave: ({ name, directives, types }) => join(['extend union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' '),
|
|
343
|
-
},
|
|
344
|
-
EnumTypeExtension: {
|
|
345
|
-
leave: ({ name, directives, values }) => join(['extend enum', name, join(directives, ' '), block(values)], ' '),
|
|
346
|
-
},
|
|
347
|
-
InputObjectTypeExtension: {
|
|
348
|
-
leave: ({ name, directives, fields }) => join(['extend input', name, join(directives, ' '), block(fields)], ' '),
|
|
349
|
-
},
|
|
350
|
-
};
|
|
351
|
-
const printDocASTReducerWithComments = Object.keys(printDocASTReducer).reduce((prev, key) => ({
|
|
352
|
-
...prev,
|
|
353
|
-
[key]: {
|
|
354
|
-
leave: addDescription(printDocASTReducer[key].leave),
|
|
355
|
-
},
|
|
356
|
-
}), {});
|
|
357
|
-
/**
|
|
358
|
-
* Converts an AST into a string, using one set of reasonable
|
|
359
|
-
* formatting rules.
|
|
360
|
-
*/
|
|
361
|
-
function printWithComments(ast) {
|
|
362
|
-
return visit(ast, printDocASTReducerWithComments);
|
|
363
|
-
}
|
|
364
|
-
function isFieldDefinitionNode(node) {
|
|
365
|
-
return node.kind === 'FieldDefinition';
|
|
366
|
-
}
|
|
367
|
-
|
|
368
84
|
function directiveAlreadyExists(directivesArr, otherDirective) {
|
|
369
85
|
return !!directivesArr.find(directive => directive.name.value === otherDirective.name.value);
|
|
370
86
|
}
|
|
@@ -427,8 +143,14 @@ function mergeDirectives(d1 = [], d2 = [], config) {
|
|
|
427
143
|
return result;
|
|
428
144
|
}
|
|
429
145
|
function validateInputs(node, existingNode) {
|
|
430
|
-
const printedNode = print(
|
|
431
|
-
|
|
146
|
+
const printedNode = print({
|
|
147
|
+
...node,
|
|
148
|
+
description: undefined,
|
|
149
|
+
});
|
|
150
|
+
const printedExistingNode = print({
|
|
151
|
+
...existingNode,
|
|
152
|
+
description: undefined,
|
|
153
|
+
});
|
|
432
154
|
// eslint-disable-next-line
|
|
433
155
|
const leaveInputs = new RegExp('(directive @w*d*)|( on .*$)', 'g');
|
|
434
156
|
const sameArguments = printedNode.replace(leaveInputs, '') === printedExistingNode.replace(leaveInputs, '');
|
|
@@ -1113,61 +835,4 @@ function extractExtensionsFromSchema(schema) {
|
|
|
1113
835
|
return result;
|
|
1114
836
|
}
|
|
1115
837
|
|
|
1116
|
-
|
|
1117
|
-
requireResolversForArgs: 'ignore',
|
|
1118
|
-
requireResolversForNonScalar: 'ignore',
|
|
1119
|
-
requireResolversForAllFields: 'ignore',
|
|
1120
|
-
requireResolversForResolveType: 'ignore',
|
|
1121
|
-
requireResolversToMatchSchema: 'ignore',
|
|
1122
|
-
};
|
|
1123
|
-
/**
|
|
1124
|
-
* Synchronously merges multiple schemas, typeDefinitions and/or resolvers into a single schema.
|
|
1125
|
-
* @param config Configuration object
|
|
1126
|
-
*/
|
|
1127
|
-
function mergeSchemas(config) {
|
|
1128
|
-
const typeDefs = mergeTypeDefs([config.schemas, config.typeDefs || []], config);
|
|
1129
|
-
const extractedResolvers = [];
|
|
1130
|
-
const extractedExtensions = [];
|
|
1131
|
-
for (const schema of config.schemas) {
|
|
1132
|
-
extractedResolvers.push(getResolversFromSchema(schema));
|
|
1133
|
-
extractedExtensions.push(extractExtensionsFromSchema(schema));
|
|
1134
|
-
}
|
|
1135
|
-
extractedResolvers.push(...ensureResolvers(config));
|
|
1136
|
-
const resolvers = mergeResolvers(extractedResolvers, config);
|
|
1137
|
-
const extensions = mergeExtensions(extractedExtensions);
|
|
1138
|
-
return makeSchema({ resolvers, typeDefs, extensions }, config);
|
|
1139
|
-
}
|
|
1140
|
-
/**
|
|
1141
|
-
* Asynchronously merges multiple schemas, typeDefinitions and/or resolvers into a single schema.
|
|
1142
|
-
* @param config Configuration object
|
|
1143
|
-
*/
|
|
1144
|
-
async function mergeSchemasAsync(config) {
|
|
1145
|
-
const [typeDefs, resolvers, extensions] = await Promise.all([
|
|
1146
|
-
mergeTypeDefs([config.schemas, config.typeDefs || []], config),
|
|
1147
|
-
Promise.all(config.schemas.map(async (schema) => getResolversFromSchema(schema))).then(extractedResolvers => mergeResolvers([...extractedResolvers, ...ensureResolvers(config)], config)),
|
|
1148
|
-
Promise.all(config.schemas.map(async (schema) => extractExtensionsFromSchema(schema))).then(extractedExtensions => mergeExtensions(extractedExtensions)),
|
|
1149
|
-
]);
|
|
1150
|
-
return makeSchema({ resolvers, typeDefs, extensions }, config);
|
|
1151
|
-
}
|
|
1152
|
-
function ensureResolvers(config) {
|
|
1153
|
-
return config.resolvers ? asArray(config.resolvers) : [];
|
|
1154
|
-
}
|
|
1155
|
-
function makeSchema({ resolvers, typeDefs, extensions, }, config) {
|
|
1156
|
-
let schema = typeof typeDefs === 'string' ? buildSchema(typeDefs, config) : buildASTSchema(typeDefs, config);
|
|
1157
|
-
// add resolvers
|
|
1158
|
-
if (resolvers) {
|
|
1159
|
-
schema = addResolversToSchema({
|
|
1160
|
-
schema,
|
|
1161
|
-
resolvers,
|
|
1162
|
-
resolverValidationOptions: {
|
|
1163
|
-
...defaultResolverValidationOptions,
|
|
1164
|
-
...(config.resolverValidationOptions || {}),
|
|
1165
|
-
},
|
|
1166
|
-
});
|
|
1167
|
-
}
|
|
1168
|
-
// extensions
|
|
1169
|
-
applyExtensions(schema, extensions);
|
|
1170
|
-
return schema;
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
export { CompareVal, applyExtensions, collectComment, defaultStringComparator, extractExtensionsFromSchema, extractType, isListTypeNode, isNamedDefinitionNode, isNonNullTypeNode, isSourceTypes, isStringTypes, isWrappingTypeNode, mergeArguments, mergeDirective, mergeDirectives, mergeEnum, mergeEnumValues, mergeExtensions, mergeFields, mergeGraphQLNodes, mergeGraphQLTypes, mergeInputType, mergeInterface, mergeNamedTypeArray, mergeResolvers, mergeScalar, mergeSchemas, mergeSchemasAsync, mergeType, mergeTypeDefs, mergeUnion, printComment, printTypeNode, printWithComments, pushComment, resetComments, schemaDefSymbol, travelSchemaPossibleExtensions };
|
|
838
|
+
export { CompareVal, applyExtensions, defaultStringComparator, extractExtensionsFromSchema, extractType, isListTypeNode, isNamedDefinitionNode, isNonNullTypeNode, isSourceTypes, isStringTypes, isWrappingTypeNode, mergeArguments, mergeDirective, mergeDirectives, mergeEnum, mergeEnumValues, mergeExtensions, mergeFields, mergeGraphQLNodes, mergeGraphQLTypes, mergeInputType, mergeInterface, mergeNamedTypeArray, mergeResolvers, mergeScalar, mergeType, mergeTypeDefs, mergeUnion, printTypeNode, schemaDefSymbol, travelSchemaPossibleExtensions };
|
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/merge",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.1",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-tools/
|
|
11
|
-
"@graphql-tools/utils": "8.0.2",
|
|
10
|
+
"@graphql-tools/utils": "8.1.1",
|
|
12
11
|
"tslib": "~2.3.0"
|
|
13
12
|
},
|
|
14
13
|
"repository": {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { Config } from './merge-typedefs';
|
|
2
|
-
import { DefinitionNode,
|
|
2
|
+
import { DefinitionNode, SchemaDefinitionNode, SchemaExtensionNode } from 'graphql';
|
|
3
|
+
import { NamedDefinitionNode } from '@graphql-tools/utils';
|
|
3
4
|
export declare const schemaDefSymbol = "SCHEMA_DEF_SYMBOL";
|
|
4
5
|
export declare type MergedResultMap = Record<string, NamedDefinitionNode> & {
|
|
5
6
|
[schemaDefSymbol]: SchemaDefinitionNode | SchemaExtensionNode;
|
|
6
7
|
};
|
|
7
|
-
export declare type NamedDefinitionNode = DefinitionNode & {
|
|
8
|
-
name?: NameNode;
|
|
9
|
-
};
|
|
10
8
|
export declare function isNamedDefinitionNode(definitionNode: DefinitionNode): definitionNode is NamedDefinitionNode;
|
|
11
9
|
export declare function mergeGraphQLNodes(nodes: ReadonlyArray<DefinitionNode>, config?: Config): MergedResultMap;
|
package/es5/merge-schemas.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { GraphQLSchema, BuildSchemaOptions } from 'graphql';
|
|
2
|
-
import { Config } from './typedefs-mergers/merge-typedefs';
|
|
3
|
-
import { IResolvers, IResolverValidationOptions, TypeSource } from '@graphql-tools/utils';
|
|
4
|
-
/**
|
|
5
|
-
* Configuration object for schema merging
|
|
6
|
-
*/
|
|
7
|
-
export interface MergeSchemasConfig<Resolvers extends IResolvers = IResolvers> extends Config, BuildSchemaOptions {
|
|
8
|
-
/**
|
|
9
|
-
* The schemas to be merged
|
|
10
|
-
*/
|
|
11
|
-
schemas: GraphQLSchema[];
|
|
12
|
-
/**
|
|
13
|
-
* Additional type definitions to also merge
|
|
14
|
-
*/
|
|
15
|
-
typeDefs?: TypeSource;
|
|
16
|
-
/**
|
|
17
|
-
* Additional resolvers to also merge
|
|
18
|
-
*/
|
|
19
|
-
resolvers?: Resolvers | Resolvers[];
|
|
20
|
-
/**
|
|
21
|
-
* Options to validate the resolvers being merged, if provided
|
|
22
|
-
*/
|
|
23
|
-
resolverValidationOptions?: IResolverValidationOptions;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Synchronously merges multiple schemas, typeDefinitions and/or resolvers into a single schema.
|
|
27
|
-
* @param config Configuration object
|
|
28
|
-
*/
|
|
29
|
-
export declare function mergeSchemas(config: MergeSchemasConfig): GraphQLSchema;
|
|
30
|
-
/**
|
|
31
|
-
* Asynchronously merges multiple schemas, typeDefinitions and/or resolvers into a single schema.
|
|
32
|
-
* @param config Configuration object
|
|
33
|
-
*/
|
|
34
|
-
export declare function mergeSchemasAsync(config: MergeSchemasConfig): Promise<GraphQLSchema>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ASTNode } from 'graphql';
|
|
2
|
-
import { NamedDefinitionNode } from './merge-nodes';
|
|
3
|
-
export declare function resetComments(): void;
|
|
4
|
-
export declare function collectComment(node: NamedDefinitionNode): void;
|
|
5
|
-
export declare function pushComment(node: any, entity: string, field?: string, argument?: string): void;
|
|
6
|
-
export declare function printComment(comment: string): string;
|
|
7
|
-
/**
|
|
8
|
-
* Converts an AST into a string, using one set of reasonable
|
|
9
|
-
* formatting rules.
|
|
10
|
-
*/
|
|
11
|
-
export declare function printWithComments(ast: ASTNode): any;
|
package/merge-schemas.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { GraphQLSchema, BuildSchemaOptions } from 'graphql';
|
|
2
|
-
import { Config } from './typedefs-mergers/merge-typedefs';
|
|
3
|
-
import { IResolvers, IResolverValidationOptions, TypeSource } from '@graphql-tools/utils';
|
|
4
|
-
/**
|
|
5
|
-
* Configuration object for schema merging
|
|
6
|
-
*/
|
|
7
|
-
export interface MergeSchemasConfig<Resolvers extends IResolvers = IResolvers> extends Config, BuildSchemaOptions {
|
|
8
|
-
/**
|
|
9
|
-
* The schemas to be merged
|
|
10
|
-
*/
|
|
11
|
-
schemas: GraphQLSchema[];
|
|
12
|
-
/**
|
|
13
|
-
* Additional type definitions to also merge
|
|
14
|
-
*/
|
|
15
|
-
typeDefs?: TypeSource;
|
|
16
|
-
/**
|
|
17
|
-
* Additional resolvers to also merge
|
|
18
|
-
*/
|
|
19
|
-
resolvers?: Resolvers | Resolvers[];
|
|
20
|
-
/**
|
|
21
|
-
* Options to validate the resolvers being merged, if provided
|
|
22
|
-
*/
|
|
23
|
-
resolverValidationOptions?: IResolverValidationOptions;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Synchronously merges multiple schemas, typeDefinitions and/or resolvers into a single schema.
|
|
27
|
-
* @param config Configuration object
|
|
28
|
-
*/
|
|
29
|
-
export declare function mergeSchemas(config: MergeSchemasConfig): GraphQLSchema;
|
|
30
|
-
/**
|
|
31
|
-
* Asynchronously merges multiple schemas, typeDefinitions and/or resolvers into a single schema.
|
|
32
|
-
* @param config Configuration object
|
|
33
|
-
*/
|
|
34
|
-
export declare function mergeSchemasAsync(config: MergeSchemasConfig): Promise<GraphQLSchema>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ASTNode } from 'graphql';
|
|
2
|
-
import { NamedDefinitionNode } from './merge-nodes';
|
|
3
|
-
export declare function resetComments(): void;
|
|
4
|
-
export declare function collectComment(node: NamedDefinitionNode): void;
|
|
5
|
-
export declare function pushComment(node: any, entity: string, field?: string, argument?: string): void;
|
|
6
|
-
export declare function printComment(comment: string): string;
|
|
7
|
-
/**
|
|
8
|
-
* Converts an AST into a string, using one set of reasonable
|
|
9
|
-
* formatting rules.
|
|
10
|
-
*/
|
|
11
|
-
export declare function printWithComments(ast: ASTNode): any;
|