@graphql-mesh/config 4.0.0-alpha-aa19542a6.0 → 4.0.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.
Files changed (4) hide show
  1. package/index.js +17 -20
  2. package/index.mjs +17 -20
  3. package/package.json +9 -9
  4. package/utils.d.ts +1 -1
package/index.js CHANGED
@@ -67,7 +67,7 @@ async function resolveAdditionalTypeDefs(baseDir, additionalTypeDefs) {
67
67
  }
68
68
  async function resolveCustomFetch({ fetchConfig, importFn, cwd, cache, additionalPackagePrefixes, }) {
69
69
  let importCode = '';
70
- if (fetchConfig) {
70
+ if (!fetchConfig) {
71
71
  importCode += `import { fetchFactory } from 'fetchache';\n`;
72
72
  importCode += `import { fetch, Request, Response } from 'cross-undici-fetch';\n`;
73
73
  return {
@@ -88,7 +88,7 @@ async function resolveCustomFetch({ fetchConfig, importFn, cwd, cache, additiona
88
88
  cwd,
89
89
  additionalPrefixes: additionalPackagePrefixes,
90
90
  });
91
- importCode += `import fetchFn from '${moduleName}';\n`;
91
+ importCode += `import fetchFn from ${JSON.stringify(moduleName)};\n`;
92
92
  return {
93
93
  fetchFn,
94
94
  importCode,
@@ -97,7 +97,7 @@ async function resolveCustomFetch({ fetchConfig, importFn, cwd, cache, additiona
97
97
  }
98
98
  async function resolveCache(cacheConfig = {
99
99
  localforage: {},
100
- }, importFn, rootStore, cwd, pubsub, additionalPackagePrefixes) {
100
+ }, importFn, rootStore, cwd, pubsub, logger, additionalPackagePrefixes) {
101
101
  const cacheName = Object.keys(cacheConfig)[0].toString();
102
102
  const config = cacheConfig[cacheName];
103
103
  const { moduleName, resolved: Cache } = await getPackage({
@@ -112,12 +112,14 @@ async function resolveCache(cacheConfig = {
112
112
  importFn,
113
113
  store: rootStore.child('cache'),
114
114
  pubsub,
115
+ logger,
115
116
  });
116
117
  const code = `const cache = new (MeshCache as any)({
117
118
  ...(${JSON.stringify(config)} as any),
118
119
  importFn,
119
120
  store: rootStore.child('cache'),
120
121
  pubsub,
122
+ logger,
121
123
  } as any)`;
122
124
  const importCode = `import MeshCache from ${JSON.stringify(moduleName)};`;
123
125
  return {
@@ -322,25 +324,23 @@ async function processConfig(config, options) {
322
324
  const { pubsub, importCode: pubsubImportCode, code: pubsubCode, } = await resolvePubSub(config.pubsub, importFn, dir, additionalPackagePrefixes);
323
325
  importCodes.push(pubsubImportCode);
324
326
  codes.push(pubsubCode);
325
- const { cache, importCode: cacheImportCode, code: cacheCode, } = await resolveCache(config.cache, importFn, rootStore, dir, pubsub, additionalPackagePrefixes);
326
- importCodes.push(cacheImportCode);
327
- codes.push(cacheCode);
328
- if (config.customFetch) {
329
- importCodes.push(`import fetchFn from ${JSON.stringify(config.customFetch)}`);
330
- }
331
- else {
332
- importCodes.push(`import { fetchFactory } from 'fetchache';`);
333
- importCodes.push(`import { fetch, Request, Response } from 'cross-undici-fetch';`);
334
- codes.push('const fetchFn = fetchFactory({ cache, fetch, Request, Response });');
335
- }
336
- const { fetchFn, importCode: fetchFnImportCode, code: fetchFnCode, } = await resolveFetch(config.customFetch);
337
- importCodes.push(fetchFnImportCode);
338
- codes.push(fetchFnCode);
339
327
  const sourcesStore = rootStore.child('sources');
340
328
  codes.push(`const sourcesStore = rootStore.child('sources');`);
341
329
  const { logger, importCode: loggerImportCode, code: loggerCode, } = await resolveLogger(config.logger, importFn, dir, additionalPackagePrefixes, options === null || options === void 0 ? void 0 : options.initialLoggerPrefix);
342
330
  importCodes.push(loggerImportCode);
343
331
  codes.push(loggerCode);
332
+ const { cache, importCode: cacheImportCode, code: cacheCode, } = await resolveCache(config.cache, importFn, rootStore, dir, pubsub, logger, additionalPackagePrefixes);
333
+ importCodes.push(cacheImportCode);
334
+ codes.push(cacheCode);
335
+ const { fetchFn, importCode: fetchFnImportCode, code: fetchFnCode, } = await resolveCustomFetch({
336
+ fetchConfig: config.customFetch,
337
+ cache,
338
+ importFn,
339
+ cwd: dir,
340
+ additionalPackagePrefixes,
341
+ });
342
+ importCodes.push(fetchFnImportCode);
343
+ codes.push(fetchFnCode);
344
344
  codes.push(`const sources = [];`);
345
345
  codes.push(`const transforms = [];`);
346
346
  codes.push(`const additionalEnvelopPlugins = [];`);
@@ -701,9 +701,6 @@ async function processConfig(config, options) {
701
701
  code: [...new Set([...importCodes, ...codes])].join('\n'),
702
702
  };
703
703
  }
704
- function resolveFetch(customFetch, importFn, dir, additionalPackagePrefixes) {
705
- throw new Error('Function not implemented.');
706
- }
707
704
 
708
705
  exports.getPackage = getPackage;
709
706
  exports.processConfig = processConfig;
package/index.mjs CHANGED
@@ -63,7 +63,7 @@ async function resolveAdditionalTypeDefs(baseDir, additionalTypeDefs) {
63
63
  }
64
64
  async function resolveCustomFetch({ fetchConfig, importFn, cwd, cache, additionalPackagePrefixes, }) {
65
65
  let importCode = '';
66
- if (fetchConfig) {
66
+ if (!fetchConfig) {
67
67
  importCode += `import { fetchFactory } from 'fetchache';\n`;
68
68
  importCode += `import { fetch, Request, Response } from 'cross-undici-fetch';\n`;
69
69
  return {
@@ -84,7 +84,7 @@ async function resolveCustomFetch({ fetchConfig, importFn, cwd, cache, additiona
84
84
  cwd,
85
85
  additionalPrefixes: additionalPackagePrefixes,
86
86
  });
87
- importCode += `import fetchFn from '${moduleName}';\n`;
87
+ importCode += `import fetchFn from ${JSON.stringify(moduleName)};\n`;
88
88
  return {
89
89
  fetchFn,
90
90
  importCode,
@@ -93,7 +93,7 @@ async function resolveCustomFetch({ fetchConfig, importFn, cwd, cache, additiona
93
93
  }
94
94
  async function resolveCache(cacheConfig = {
95
95
  localforage: {},
96
- }, importFn, rootStore, cwd, pubsub, additionalPackagePrefixes) {
96
+ }, importFn, rootStore, cwd, pubsub, logger, additionalPackagePrefixes) {
97
97
  const cacheName = Object.keys(cacheConfig)[0].toString();
98
98
  const config = cacheConfig[cacheName];
99
99
  const { moduleName, resolved: Cache } = await getPackage({
@@ -108,12 +108,14 @@ async function resolveCache(cacheConfig = {
108
108
  importFn,
109
109
  store: rootStore.child('cache'),
110
110
  pubsub,
111
+ logger,
111
112
  });
112
113
  const code = `const cache = new (MeshCache as any)({
113
114
  ...(${JSON.stringify(config)} as any),
114
115
  importFn,
115
116
  store: rootStore.child('cache'),
116
117
  pubsub,
118
+ logger,
117
119
  } as any)`;
118
120
  const importCode = `import MeshCache from ${JSON.stringify(moduleName)};`;
119
121
  return {
@@ -318,25 +320,23 @@ async function processConfig(config, options) {
318
320
  const { pubsub, importCode: pubsubImportCode, code: pubsubCode, } = await resolvePubSub(config.pubsub, importFn, dir, additionalPackagePrefixes);
319
321
  importCodes.push(pubsubImportCode);
320
322
  codes.push(pubsubCode);
321
- const { cache, importCode: cacheImportCode, code: cacheCode, } = await resolveCache(config.cache, importFn, rootStore, dir, pubsub, additionalPackagePrefixes);
322
- importCodes.push(cacheImportCode);
323
- codes.push(cacheCode);
324
- if (config.customFetch) {
325
- importCodes.push(`import fetchFn from ${JSON.stringify(config.customFetch)}`);
326
- }
327
- else {
328
- importCodes.push(`import { fetchFactory } from 'fetchache';`);
329
- importCodes.push(`import { fetch, Request, Response } from 'cross-undici-fetch';`);
330
- codes.push('const fetchFn = fetchFactory({ cache, fetch, Request, Response });');
331
- }
332
- const { fetchFn, importCode: fetchFnImportCode, code: fetchFnCode, } = await resolveFetch(config.customFetch);
333
- importCodes.push(fetchFnImportCode);
334
- codes.push(fetchFnCode);
335
323
  const sourcesStore = rootStore.child('sources');
336
324
  codes.push(`const sourcesStore = rootStore.child('sources');`);
337
325
  const { logger, importCode: loggerImportCode, code: loggerCode, } = await resolveLogger(config.logger, importFn, dir, additionalPackagePrefixes, options === null || options === void 0 ? void 0 : options.initialLoggerPrefix);
338
326
  importCodes.push(loggerImportCode);
339
327
  codes.push(loggerCode);
328
+ const { cache, importCode: cacheImportCode, code: cacheCode, } = await resolveCache(config.cache, importFn, rootStore, dir, pubsub, logger, additionalPackagePrefixes);
329
+ importCodes.push(cacheImportCode);
330
+ codes.push(cacheCode);
331
+ const { fetchFn, importCode: fetchFnImportCode, code: fetchFnCode, } = await resolveCustomFetch({
332
+ fetchConfig: config.customFetch,
333
+ cache,
334
+ importFn,
335
+ cwd: dir,
336
+ additionalPackagePrefixes,
337
+ });
338
+ importCodes.push(fetchFnImportCode);
339
+ codes.push(fetchFnCode);
340
340
  codes.push(`const sources = [];`);
341
341
  codes.push(`const transforms = [];`);
342
342
  codes.push(`const additionalEnvelopPlugins = [];`);
@@ -697,8 +697,5 @@ async function processConfig(config, options) {
697
697
  code: [...new Set([...importCodes, ...codes])].join('\n'),
698
698
  };
699
699
  }
700
- function resolveFetch(customFetch, importFn, dir, additionalPackagePrefixes) {
701
- throw new Error('Function not implemented.');
702
- }
703
700
 
704
701
  export { getPackage, processConfig, resolveAdditionalTypeDefs, resolveCache, resolveCustomFetch, resolveDocuments, resolveLogger, resolvePubSub };
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@graphql-mesh/config",
3
- "version": "4.0.0-alpha-aa19542a6.0",
3
+ "version": "4.0.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@graphql-mesh/runtime": "0.40.0-alpha-aa19542a6.0",
6
+ "@graphql-mesh/runtime": "^0.40.0",
7
7
  "graphql": "*"
8
8
  },
9
9
  "dependencies": {
10
10
  "@envelop/core": "2.4.0",
11
- "@graphql-mesh/cache-localforage": "0.6.16-alpha-aa19542a6.0",
12
- "@graphql-mesh/cross-helpers": "0.2.0-alpha-aa19542a6.0",
13
- "@graphql-mesh/merger-bare": "0.14.2-alpha-aa19542a6.0",
14
- "@graphql-mesh/merger-stitching": "0.15.60-alpha-aa19542a6.0",
15
- "@graphql-mesh/store": "0.8.19-alpha-aa19542a6.0",
16
- "@graphql-mesh/types": "0.77.1-alpha-aa19542a6.0",
17
- "@graphql-mesh/utils": "0.37.0-alpha-aa19542a6.0",
11
+ "@graphql-mesh/cache-localforage": "0.6.16",
12
+ "@graphql-mesh/cross-helpers": "0.2.0",
13
+ "@graphql-mesh/merger-bare": "0.14.2",
14
+ "@graphql-mesh/merger-stitching": "0.15.60",
15
+ "@graphql-mesh/store": "0.8.19",
16
+ "@graphql-mesh/types": "0.77.1",
17
+ "@graphql-mesh/utils": "0.37.0",
18
18
  "@graphql-tools/code-file-loader": "7.3.0",
19
19
  "@graphql-tools/graphql-file-loader": "7.4.0",
20
20
  "@graphql-tools/load": "7.7.0",
package/utils.d.ts CHANGED
@@ -26,7 +26,7 @@ export declare function resolveCustomFetch({ fetchConfig, importFn, cwd, cache,
26
26
  importCode: string;
27
27
  code: string;
28
28
  }>;
29
- export declare function resolveCache(cacheConfig: YamlConfig.Config['cache'], importFn: ImportFn, rootStore: MeshStore, cwd: string, pubsub: MeshPubSub, additionalPackagePrefixes: string[]): Promise<{
29
+ export declare function resolveCache(cacheConfig: YamlConfig.Config['cache'], importFn: ImportFn, rootStore: MeshStore, cwd: string, pubsub: MeshPubSub, logger: Logger, additionalPackagePrefixes: string[]): Promise<{
30
30
  cache: KeyValueCache;
31
31
  importCode: string;
32
32
  code: string;