@graphql-mesh/config 1.0.0 → 2.0.0-alpha-a952bb598.0
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 +27 -37
- package/index.mjs +27 -37
- package/package.json +8 -8
package/index.js
CHANGED
|
@@ -212,7 +212,7 @@ async function processConfig(config, options) {
|
|
|
212
212
|
`export const rawServeConfig: YamlConfig.Config['serve'] = ${JSON.stringify(config.serve)} as any`,
|
|
213
213
|
`export async function getMeshOptions(): Promise<GetMeshOptions> {`,
|
|
214
214
|
];
|
|
215
|
-
const { dir, importFn = utils$1.defaultImportFn, store: providedStore, artifactsDir, additionalPackagePrefixes, } = options || {};
|
|
215
|
+
const { dir, importFn = utils$1.defaultImportFn, store: providedStore, artifactsDir, additionalPackagePrefixes = [], } = options || {};
|
|
216
216
|
if (config.require) {
|
|
217
217
|
await Promise.all(config.require.map(mod => importFn(mod)));
|
|
218
218
|
for (const mod of config.require) {
|
|
@@ -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,11 @@ 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
|
+
cache,
|
|
383
|
+
})`);
|
|
387
384
|
}
|
|
388
385
|
}
|
|
389
386
|
else {
|
|
@@ -392,7 +389,7 @@ async function processConfig(config, options) {
|
|
|
392
389
|
pluginFactory = possiblePluginFactory[key];
|
|
393
390
|
if (options.generateCode) {
|
|
394
391
|
importCodes.push(`import { ${importName} } from ${JSON.stringify(moduleName)};`);
|
|
395
|
-
codes.push(`additionalEnvelopPlugins
|
|
392
|
+
codes.push(`additionalEnvelopPlugins[${pluginIndex}] = ${importName}(${JSON.stringify(pluginConfig, null, 2)}]`);
|
|
396
393
|
}
|
|
397
394
|
}
|
|
398
395
|
});
|
|
@@ -400,6 +397,7 @@ async function processConfig(config, options) {
|
|
|
400
397
|
return pluginFactory({
|
|
401
398
|
...pluginConfig,
|
|
402
399
|
logger: logger.child(pluginName),
|
|
400
|
+
cache,
|
|
403
401
|
});
|
|
404
402
|
})) || []),
|
|
405
403
|
resolveAdditionalTypeDefs(dir, config.additionalTypeDefs).then(additionalTypeDefs => {
|
|
@@ -442,37 +440,29 @@ async function processConfig(config, options) {
|
|
|
442
440
|
]);
|
|
443
441
|
if (options.generateCode) {
|
|
444
442
|
if ((_c = config.additionalResolvers) === null || _c === void 0 ? void 0 : _c.length) {
|
|
445
|
-
importCodes.push(`import {
|
|
446
|
-
codes.push(`const
|
|
447
|
-
|
|
448
|
-
|
|
443
|
+
importCodes.push(`import { resolveAdditionalResolversWithoutImport } from '@graphql-mesh/utils';`);
|
|
444
|
+
codes.push(`const additionalResolvers = await Promise.all([
|
|
445
|
+
${config.additionalResolvers
|
|
446
|
+
.map(additionalResolverDefinition => {
|
|
449
447
|
if (typeof additionalResolverDefinition === 'string') {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
.split('\\')
|
|
453
|
-
.join('/')}';`);
|
|
454
|
-
codes.push(`additionalResolversRawConfig.push(additionalResolvers$${additionalResolverDefinitionIndex}.resolvers || additionalResolvers$${additionalResolverDefinitionIndex}.default || additionalResolvers$${additionalResolverDefinitionIndex})`);
|
|
448
|
+
return `import(${JSON.stringify(crossHelpers.path.join('..', additionalResolverDefinition).split('\\').join('/'))})
|
|
449
|
+
.then(m => m.resolvers || m.default || m)`;
|
|
455
450
|
}
|
|
456
451
|
else {
|
|
457
|
-
|
|
452
|
+
return `resolveAdditionalResolversWithoutImport(
|
|
453
|
+
${JSON.stringify(additionalResolverDefinition, null, 2)}
|
|
454
|
+
)`;
|
|
458
455
|
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
additionalResolversRawConfig,
|
|
463
|
-
importFn,
|
|
464
|
-
pubsub
|
|
465
|
-
)`);
|
|
456
|
+
})
|
|
457
|
+
.join(',\n')}
|
|
458
|
+
]);`);
|
|
466
459
|
}
|
|
467
460
|
else {
|
|
468
461
|
codes.push(`const additionalResolvers = [] as any[]`);
|
|
469
462
|
}
|
|
470
463
|
}
|
|
471
464
|
if (config.additionalEnvelopPlugins) {
|
|
472
|
-
|
|
473
|
-
.join('..', config.additionalEnvelopPlugins)
|
|
474
|
-
.split('\\')
|
|
475
|
-
.join('/')}';`);
|
|
465
|
+
codes.push(`const importedAdditionalEnvelopPlugins = await import(${JSON.stringify(crossHelpers.path.join('..', config.additionalEnvelopPlugins).split('\\').join('/'))}).then(m => m.default || m);`);
|
|
476
466
|
const importedAdditionalEnvelopPlugins = await importFn(crossHelpers.path.isAbsolute(config.additionalEnvelopPlugins)
|
|
477
467
|
? config.additionalEnvelopPlugins
|
|
478
468
|
: crossHelpers.path.join(dir, config.additionalEnvelopPlugins));
|
package/index.mjs
CHANGED
|
@@ -208,7 +208,7 @@ async function processConfig(config, options) {
|
|
|
208
208
|
`export const rawServeConfig: YamlConfig.Config['serve'] = ${JSON.stringify(config.serve)} as any`,
|
|
209
209
|
`export async function getMeshOptions(): Promise<GetMeshOptions> {`,
|
|
210
210
|
];
|
|
211
|
-
const { dir, importFn = defaultImportFn, store: providedStore, artifactsDir, additionalPackagePrefixes, } = options || {};
|
|
211
|
+
const { dir, importFn = defaultImportFn, store: providedStore, artifactsDir, additionalPackagePrefixes = [], } = options || {};
|
|
212
212
|
if (config.require) {
|
|
213
213
|
await Promise.all(config.require.map(mod => importFn(mod)));
|
|
214
214
|
for (const mod of config.require) {
|
|
@@ -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,11 @@ 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
|
+
cache,
|
|
379
|
+
})`);
|
|
383
380
|
}
|
|
384
381
|
}
|
|
385
382
|
else {
|
|
@@ -388,7 +385,7 @@ async function processConfig(config, options) {
|
|
|
388
385
|
pluginFactory = possiblePluginFactory[key];
|
|
389
386
|
if (options.generateCode) {
|
|
390
387
|
importCodes.push(`import { ${importName} } from ${JSON.stringify(moduleName)};`);
|
|
391
|
-
codes.push(`additionalEnvelopPlugins
|
|
388
|
+
codes.push(`additionalEnvelopPlugins[${pluginIndex}] = ${importName}(${JSON.stringify(pluginConfig, null, 2)}]`);
|
|
392
389
|
}
|
|
393
390
|
}
|
|
394
391
|
});
|
|
@@ -396,6 +393,7 @@ async function processConfig(config, options) {
|
|
|
396
393
|
return pluginFactory({
|
|
397
394
|
...pluginConfig,
|
|
398
395
|
logger: logger.child(pluginName),
|
|
396
|
+
cache,
|
|
399
397
|
});
|
|
400
398
|
})) || []),
|
|
401
399
|
resolveAdditionalTypeDefs(dir, config.additionalTypeDefs).then(additionalTypeDefs => {
|
|
@@ -438,37 +436,29 @@ async function processConfig(config, options) {
|
|
|
438
436
|
]);
|
|
439
437
|
if (options.generateCode) {
|
|
440
438
|
if ((_c = config.additionalResolvers) === null || _c === void 0 ? void 0 : _c.length) {
|
|
441
|
-
importCodes.push(`import {
|
|
442
|
-
codes.push(`const
|
|
443
|
-
|
|
444
|
-
|
|
439
|
+
importCodes.push(`import { resolveAdditionalResolversWithoutImport } from '@graphql-mesh/utils';`);
|
|
440
|
+
codes.push(`const additionalResolvers = await Promise.all([
|
|
441
|
+
${config.additionalResolvers
|
|
442
|
+
.map(additionalResolverDefinition => {
|
|
445
443
|
if (typeof additionalResolverDefinition === 'string') {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
.split('\\')
|
|
449
|
-
.join('/')}';`);
|
|
450
|
-
codes.push(`additionalResolversRawConfig.push(additionalResolvers$${additionalResolverDefinitionIndex}.resolvers || additionalResolvers$${additionalResolverDefinitionIndex}.default || additionalResolvers$${additionalResolverDefinitionIndex})`);
|
|
444
|
+
return `import(${JSON.stringify(path.join('..', additionalResolverDefinition).split('\\').join('/'))})
|
|
445
|
+
.then(m => m.resolvers || m.default || m)`;
|
|
451
446
|
}
|
|
452
447
|
else {
|
|
453
|
-
|
|
448
|
+
return `resolveAdditionalResolversWithoutImport(
|
|
449
|
+
${JSON.stringify(additionalResolverDefinition, null, 2)}
|
|
450
|
+
)`;
|
|
454
451
|
}
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
additionalResolversRawConfig,
|
|
459
|
-
importFn,
|
|
460
|
-
pubsub
|
|
461
|
-
)`);
|
|
452
|
+
})
|
|
453
|
+
.join(',\n')}
|
|
454
|
+
]);`);
|
|
462
455
|
}
|
|
463
456
|
else {
|
|
464
457
|
codes.push(`const additionalResolvers = [] as any[]`);
|
|
465
458
|
}
|
|
466
459
|
}
|
|
467
460
|
if (config.additionalEnvelopPlugins) {
|
|
468
|
-
|
|
469
|
-
.join('..', config.additionalEnvelopPlugins)
|
|
470
|
-
.split('\\')
|
|
471
|
-
.join('/')}';`);
|
|
461
|
+
codes.push(`const importedAdditionalEnvelopPlugins = await import(${JSON.stringify(path.join('..', config.additionalEnvelopPlugins).split('\\').join('/'))}).then(m => m.default || m);`);
|
|
472
462
|
const importedAdditionalEnvelopPlugins = await importFn(path.isAbsolute(config.additionalEnvelopPlugins)
|
|
473
463
|
? config.additionalEnvelopPlugins
|
|
474
464
|
: path.join(dir, config.additionalEnvelopPlugins));
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha-a952bb598.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@graphql-mesh/runtime": "
|
|
6
|
+
"@graphql-mesh/runtime": "0.38.0-alpha-a952bb598.0",
|
|
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.13-alpha-a952bb598.0",
|
|
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.
|
|
17
|
-
"@graphql-mesh/utils": "0.35.
|
|
13
|
+
"@graphql-mesh/merger-bare": "0.13.55-alpha-a952bb598.0",
|
|
14
|
+
"@graphql-mesh/merger-stitching": "0.15.57-alpha-a952bb598.0",
|
|
15
|
+
"@graphql-mesh/store": "0.8.16-alpha-a952bb598.0",
|
|
16
|
+
"@graphql-mesh/types": "0.75.0-alpha-a952bb598.0",
|
|
17
|
+
"@graphql-mesh/utils": "0.35.7-alpha-a952bb598.0",
|
|
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",
|