@graphql-mesh/config 1.0.0 → 1.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/index.js +24 -36
- package/index.mjs +24 -36
- package/package.json +8 -8
package/index.js
CHANGED
|
@@ -288,16 +288,14 @@ async function processConfig(config, options) {
|
|
|
288
288
|
if (options.generateCode) {
|
|
289
289
|
const transformImportName = pascalCase.pascalCase(transformName + '_Transform');
|
|
290
290
|
importCodes.push(`import ${transformImportName} from ${JSON.stringify(moduleName)};`);
|
|
291
|
-
codes.push(`${transformsVariableName}
|
|
292
|
-
new ${transformImportName}({
|
|
291
|
+
codes.push(`${transformsVariableName}[${transformIndex}] = new ${transformImportName}({
|
|
293
292
|
apiName: ${JSON.stringify(source.name)},
|
|
294
293
|
config: ${JSON.stringify(transformConfig)},
|
|
295
294
|
baseDir,
|
|
296
295
|
cache,
|
|
297
296
|
pubsub,
|
|
298
297
|
importFn
|
|
299
|
-
})
|
|
300
|
-
);`);
|
|
298
|
+
});`);
|
|
301
299
|
}
|
|
302
300
|
return new TransformCtor({
|
|
303
301
|
apiName: source.name,
|
|
@@ -310,11 +308,11 @@ async function processConfig(config, options) {
|
|
|
310
308
|
})),
|
|
311
309
|
]);
|
|
312
310
|
if (options.generateCode) {
|
|
313
|
-
codes.push(`sources
|
|
311
|
+
codes.push(`sources[${sourceIndex}] = {
|
|
314
312
|
name: '${source.name}',
|
|
315
313
|
handler: ${handlerVariableName},
|
|
316
314
|
transforms: ${transformsVariableName}
|
|
317
|
-
}
|
|
315
|
+
}`);
|
|
318
316
|
}
|
|
319
317
|
return {
|
|
320
318
|
name: source.name,
|
|
@@ -335,16 +333,14 @@ async function processConfig(config, options) {
|
|
|
335
333
|
if (options.generateCode) {
|
|
336
334
|
const transformImportName = pascalCase.pascalCase(transformName + '_Transform');
|
|
337
335
|
importCodes.push(`import ${transformImportName} from ${JSON.stringify(moduleName)};`);
|
|
338
|
-
codes.push(`transforms
|
|
339
|
-
new (${transformImportName} as any)({
|
|
336
|
+
codes.push(`transforms[${transformIndex}] = new (${transformImportName} as any)({
|
|
340
337
|
apiName: '',
|
|
341
338
|
config: ${JSON.stringify(transformConfig)},
|
|
342
339
|
baseDir,
|
|
343
340
|
cache,
|
|
344
341
|
pubsub,
|
|
345
342
|
importFn
|
|
346
|
-
})
|
|
347
|
-
)`);
|
|
343
|
+
})`);
|
|
348
344
|
}
|
|
349
345
|
return new TransformLibrary({
|
|
350
346
|
apiName: '',
|
|
@@ -362,7 +358,7 @@ async function processConfig(config, options) {
|
|
|
362
358
|
const { importName, moduleName, pluginFactory } = ENVELOP_CORE_PLUGINS_MAP[pluginName];
|
|
363
359
|
if (options.generateCode) {
|
|
364
360
|
importCodes.push(`import { ${importName} } from ${JSON.stringify(moduleName)};`);
|
|
365
|
-
codes.push(`additionalEnvelopPlugins
|
|
361
|
+
codes.push(`additionalEnvelopPlugins[${pluginIndex}] = ${importName}(${JSON.stringify(pluginConfig, null, 2)}))`);
|
|
366
362
|
}
|
|
367
363
|
return pluginFactory(pluginConfig);
|
|
368
364
|
}
|
|
@@ -380,10 +376,10 @@ async function processConfig(config, options) {
|
|
|
380
376
|
if (options.generateCode) {
|
|
381
377
|
importName = pascalCase.pascalCase('use_' + pluginName);
|
|
382
378
|
importCodes.push(`import ${importName} from ${JSON.stringify(moduleName)};`);
|
|
383
|
-
codes.push(`additionalEnvelopPlugins
|
|
384
|
-
...(${JSON.stringify(pluginConfig)}),
|
|
379
|
+
codes.push(`additionalEnvelopPlugins[${pluginIndex}] = ${importName}({
|
|
380
|
+
...(${JSON.stringify(pluginConfig, null, 2)}),
|
|
385
381
|
logger: logger.child(${JSON.stringify(pluginName)}),
|
|
386
|
-
})
|
|
382
|
+
})`);
|
|
387
383
|
}
|
|
388
384
|
}
|
|
389
385
|
else {
|
|
@@ -392,7 +388,7 @@ async function processConfig(config, options) {
|
|
|
392
388
|
pluginFactory = possiblePluginFactory[key];
|
|
393
389
|
if (options.generateCode) {
|
|
394
390
|
importCodes.push(`import { ${importName} } from ${JSON.stringify(moduleName)};`);
|
|
395
|
-
codes.push(`additionalEnvelopPlugins
|
|
391
|
+
codes.push(`additionalEnvelopPlugins[${pluginIndex}] = ${importName}(${JSON.stringify(pluginConfig, null, 2)}]`);
|
|
396
392
|
}
|
|
397
393
|
}
|
|
398
394
|
});
|
|
@@ -442,37 +438,29 @@ async function processConfig(config, options) {
|
|
|
442
438
|
]);
|
|
443
439
|
if (options.generateCode) {
|
|
444
440
|
if ((_c = config.additionalResolvers) === null || _c === void 0 ? void 0 : _c.length) {
|
|
445
|
-
importCodes.push(`import {
|
|
446
|
-
codes.push(`const
|
|
447
|
-
|
|
448
|
-
|
|
441
|
+
importCodes.push(`import { resolveAdditionalResolversWithoutImport } from '@graphql-mesh/utils';`);
|
|
442
|
+
codes.push(`const additionalResolvers = await Promise.all([
|
|
443
|
+
${config.additionalResolvers
|
|
444
|
+
.map(additionalResolverDefinition => {
|
|
449
445
|
if (typeof additionalResolverDefinition === 'string') {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
.split('\\')
|
|
453
|
-
.join('/')}';`);
|
|
454
|
-
codes.push(`additionalResolversRawConfig.push(additionalResolvers$${additionalResolverDefinitionIndex}.resolvers || additionalResolvers$${additionalResolverDefinitionIndex}.default || additionalResolvers$${additionalResolverDefinitionIndex})`);
|
|
446
|
+
return `import(${JSON.stringify(crossHelpers.path.join('..', additionalResolverDefinition).split('\\').join('/'))})
|
|
447
|
+
.then(m => m.resolvers || m.default || m)`;
|
|
455
448
|
}
|
|
456
449
|
else {
|
|
457
|
-
|
|
450
|
+
return `resolveAdditionalResolversWithoutImport(
|
|
451
|
+
${JSON.stringify(additionalResolverDefinition, null, 2)}
|
|
452
|
+
)`;
|
|
458
453
|
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
additionalResolversRawConfig,
|
|
463
|
-
importFn,
|
|
464
|
-
pubsub
|
|
465
|
-
)`);
|
|
454
|
+
})
|
|
455
|
+
.join(',\n')}
|
|
456
|
+
]);`);
|
|
466
457
|
}
|
|
467
458
|
else {
|
|
468
459
|
codes.push(`const additionalResolvers = [] as any[]`);
|
|
469
460
|
}
|
|
470
461
|
}
|
|
471
462
|
if (config.additionalEnvelopPlugins) {
|
|
472
|
-
|
|
473
|
-
.join('..', config.additionalEnvelopPlugins)
|
|
474
|
-
.split('\\')
|
|
475
|
-
.join('/')}';`);
|
|
463
|
+
codes.push(`const importedAdditionalEnvelopPlugins = await import(${JSON.stringify(crossHelpers.path.join('..', config.additionalEnvelopPlugins).split('\\').join('/'))}).then(m => m.default || m);`);
|
|
476
464
|
const importedAdditionalEnvelopPlugins = await importFn(crossHelpers.path.isAbsolute(config.additionalEnvelopPlugins)
|
|
477
465
|
? config.additionalEnvelopPlugins
|
|
478
466
|
: crossHelpers.path.join(dir, config.additionalEnvelopPlugins));
|
package/index.mjs
CHANGED
|
@@ -284,16 +284,14 @@ async function processConfig(config, options) {
|
|
|
284
284
|
if (options.generateCode) {
|
|
285
285
|
const transformImportName = pascalCase(transformName + '_Transform');
|
|
286
286
|
importCodes.push(`import ${transformImportName} from ${JSON.stringify(moduleName)};`);
|
|
287
|
-
codes.push(`${transformsVariableName}
|
|
288
|
-
new ${transformImportName}({
|
|
287
|
+
codes.push(`${transformsVariableName}[${transformIndex}] = new ${transformImportName}({
|
|
289
288
|
apiName: ${JSON.stringify(source.name)},
|
|
290
289
|
config: ${JSON.stringify(transformConfig)},
|
|
291
290
|
baseDir,
|
|
292
291
|
cache,
|
|
293
292
|
pubsub,
|
|
294
293
|
importFn
|
|
295
|
-
})
|
|
296
|
-
);`);
|
|
294
|
+
});`);
|
|
297
295
|
}
|
|
298
296
|
return new TransformCtor({
|
|
299
297
|
apiName: source.name,
|
|
@@ -306,11 +304,11 @@ async function processConfig(config, options) {
|
|
|
306
304
|
})),
|
|
307
305
|
]);
|
|
308
306
|
if (options.generateCode) {
|
|
309
|
-
codes.push(`sources
|
|
307
|
+
codes.push(`sources[${sourceIndex}] = {
|
|
310
308
|
name: '${source.name}',
|
|
311
309
|
handler: ${handlerVariableName},
|
|
312
310
|
transforms: ${transformsVariableName}
|
|
313
|
-
}
|
|
311
|
+
}`);
|
|
314
312
|
}
|
|
315
313
|
return {
|
|
316
314
|
name: source.name,
|
|
@@ -331,16 +329,14 @@ async function processConfig(config, options) {
|
|
|
331
329
|
if (options.generateCode) {
|
|
332
330
|
const transformImportName = pascalCase(transformName + '_Transform');
|
|
333
331
|
importCodes.push(`import ${transformImportName} from ${JSON.stringify(moduleName)};`);
|
|
334
|
-
codes.push(`transforms
|
|
335
|
-
new (${transformImportName} as any)({
|
|
332
|
+
codes.push(`transforms[${transformIndex}] = new (${transformImportName} as any)({
|
|
336
333
|
apiName: '',
|
|
337
334
|
config: ${JSON.stringify(transformConfig)},
|
|
338
335
|
baseDir,
|
|
339
336
|
cache,
|
|
340
337
|
pubsub,
|
|
341
338
|
importFn
|
|
342
|
-
})
|
|
343
|
-
)`);
|
|
339
|
+
})`);
|
|
344
340
|
}
|
|
345
341
|
return new TransformLibrary({
|
|
346
342
|
apiName: '',
|
|
@@ -358,7 +354,7 @@ async function processConfig(config, options) {
|
|
|
358
354
|
const { importName, moduleName, pluginFactory } = ENVELOP_CORE_PLUGINS_MAP[pluginName];
|
|
359
355
|
if (options.generateCode) {
|
|
360
356
|
importCodes.push(`import { ${importName} } from ${JSON.stringify(moduleName)};`);
|
|
361
|
-
codes.push(`additionalEnvelopPlugins
|
|
357
|
+
codes.push(`additionalEnvelopPlugins[${pluginIndex}] = ${importName}(${JSON.stringify(pluginConfig, null, 2)}))`);
|
|
362
358
|
}
|
|
363
359
|
return pluginFactory(pluginConfig);
|
|
364
360
|
}
|
|
@@ -376,10 +372,10 @@ async function processConfig(config, options) {
|
|
|
376
372
|
if (options.generateCode) {
|
|
377
373
|
importName = pascalCase('use_' + pluginName);
|
|
378
374
|
importCodes.push(`import ${importName} from ${JSON.stringify(moduleName)};`);
|
|
379
|
-
codes.push(`additionalEnvelopPlugins
|
|
380
|
-
...(${JSON.stringify(pluginConfig)}),
|
|
375
|
+
codes.push(`additionalEnvelopPlugins[${pluginIndex}] = ${importName}({
|
|
376
|
+
...(${JSON.stringify(pluginConfig, null, 2)}),
|
|
381
377
|
logger: logger.child(${JSON.stringify(pluginName)}),
|
|
382
|
-
})
|
|
378
|
+
})`);
|
|
383
379
|
}
|
|
384
380
|
}
|
|
385
381
|
else {
|
|
@@ -388,7 +384,7 @@ async function processConfig(config, options) {
|
|
|
388
384
|
pluginFactory = possiblePluginFactory[key];
|
|
389
385
|
if (options.generateCode) {
|
|
390
386
|
importCodes.push(`import { ${importName} } from ${JSON.stringify(moduleName)};`);
|
|
391
|
-
codes.push(`additionalEnvelopPlugins
|
|
387
|
+
codes.push(`additionalEnvelopPlugins[${pluginIndex}] = ${importName}(${JSON.stringify(pluginConfig, null, 2)}]`);
|
|
392
388
|
}
|
|
393
389
|
}
|
|
394
390
|
});
|
|
@@ -438,37 +434,29 @@ async function processConfig(config, options) {
|
|
|
438
434
|
]);
|
|
439
435
|
if (options.generateCode) {
|
|
440
436
|
if ((_c = config.additionalResolvers) === null || _c === void 0 ? void 0 : _c.length) {
|
|
441
|
-
importCodes.push(`import {
|
|
442
|
-
codes.push(`const
|
|
443
|
-
|
|
444
|
-
|
|
437
|
+
importCodes.push(`import { resolveAdditionalResolversWithoutImport } from '@graphql-mesh/utils';`);
|
|
438
|
+
codes.push(`const additionalResolvers = await Promise.all([
|
|
439
|
+
${config.additionalResolvers
|
|
440
|
+
.map(additionalResolverDefinition => {
|
|
445
441
|
if (typeof additionalResolverDefinition === 'string') {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
.split('\\')
|
|
449
|
-
.join('/')}';`);
|
|
450
|
-
codes.push(`additionalResolversRawConfig.push(additionalResolvers$${additionalResolverDefinitionIndex}.resolvers || additionalResolvers$${additionalResolverDefinitionIndex}.default || additionalResolvers$${additionalResolverDefinitionIndex})`);
|
|
442
|
+
return `import(${JSON.stringify(path.join('..', additionalResolverDefinition).split('\\').join('/'))})
|
|
443
|
+
.then(m => m.resolvers || m.default || m)`;
|
|
451
444
|
}
|
|
452
445
|
else {
|
|
453
|
-
|
|
446
|
+
return `resolveAdditionalResolversWithoutImport(
|
|
447
|
+
${JSON.stringify(additionalResolverDefinition, null, 2)}
|
|
448
|
+
)`;
|
|
454
449
|
}
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
additionalResolversRawConfig,
|
|
459
|
-
importFn,
|
|
460
|
-
pubsub
|
|
461
|
-
)`);
|
|
450
|
+
})
|
|
451
|
+
.join(',\n')}
|
|
452
|
+
]);`);
|
|
462
453
|
}
|
|
463
454
|
else {
|
|
464
455
|
codes.push(`const additionalResolvers = [] as any[]`);
|
|
465
456
|
}
|
|
466
457
|
}
|
|
467
458
|
if (config.additionalEnvelopPlugins) {
|
|
468
|
-
|
|
469
|
-
.join('..', config.additionalEnvelopPlugins)
|
|
470
|
-
.split('\\')
|
|
471
|
-
.join('/')}';`);
|
|
459
|
+
codes.push(`const importedAdditionalEnvelopPlugins = await import(${JSON.stringify(path.join('..', config.additionalEnvelopPlugins).split('\\').join('/'))}).then(m => m.default || m);`);
|
|
472
460
|
const importedAdditionalEnvelopPlugins = await importFn(path.isAbsolute(config.additionalEnvelopPlugins)
|
|
473
461
|
? config.additionalEnvelopPlugins
|
|
474
462
|
: path.join(dir, config.additionalEnvelopPlugins));
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/config",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@graphql-mesh/runtime": "^0.
|
|
6
|
+
"@graphql-mesh/runtime": "^0.37.1",
|
|
7
7
|
"graphql": "*"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@envelop/core": "2.3.3",
|
|
11
|
-
"@graphql-mesh/cache-localforage": "0.6.
|
|
11
|
+
"@graphql-mesh/cache-localforage": "0.6.12",
|
|
12
12
|
"@graphql-mesh/cross-helpers": "0.1.6",
|
|
13
|
-
"@graphql-mesh/merger-bare": "0.13.
|
|
14
|
-
"@graphql-mesh/merger-stitching": "0.15.
|
|
15
|
-
"@graphql-mesh/store": "0.8.
|
|
16
|
-
"@graphql-mesh/types": "0.74.
|
|
17
|
-
"@graphql-mesh/utils": "0.35.
|
|
13
|
+
"@graphql-mesh/merger-bare": "0.13.54",
|
|
14
|
+
"@graphql-mesh/merger-stitching": "0.15.56",
|
|
15
|
+
"@graphql-mesh/store": "0.8.15",
|
|
16
|
+
"@graphql-mesh/types": "0.74.2",
|
|
17
|
+
"@graphql-mesh/utils": "0.35.6",
|
|
18
18
|
"@graphql-tools/code-file-loader": "7.2.18",
|
|
19
19
|
"@graphql-tools/graphql-file-loader": "7.3.15",
|
|
20
20
|
"@graphql-tools/load": "7.5.14",
|