diff --git a/.changeset/@graphql-mesh_compose-cli-8082-dependencies.md b/.changeset/@graphql-mesh_compose-cli-8082-dependencies.md new file mode 100644 index 0000000000000..1787b0c027ca3 --- /dev/null +++ b/.changeset/@graphql-mesh_compose-cli-8082-dependencies.md @@ -0,0 +1,9 @@ +--- +"@graphql-mesh/compose-cli": patch +--- +dependencies updates: + - Updated dependency [`@graphql-mesh/fusion-composition@^0.7.13` ↗︎](https://www.npmjs.com/package/@graphql-mesh/fusion-composition/v/0.7.13) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@graphql-mesh/include@^0.2.6` ↗︎](https://www.npmjs.com/package/@graphql-mesh/include/v/0.2.6) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@graphql-mesh/string-interpolation@^0.5.7` ↗︎](https://www.npmjs.com/package/@graphql-mesh/string-interpolation/v/0.5.7) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@graphql-mesh/types@^0.103.7` ↗︎](https://www.npmjs.com/package/@graphql-mesh/types/v/0.103.7) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@graphql-mesh/utils@^0.103.7` ↗︎](https://www.npmjs.com/package/@graphql-mesh/utils/v/0.103.7) (from `workspace:^`, in `dependencies`) diff --git a/.changeset/@graphql-mesh_graphql-8082-dependencies.md b/.changeset/@graphql-mesh_graphql-8082-dependencies.md new file mode 100644 index 0000000000000..29750bb912f0f --- /dev/null +++ b/.changeset/@graphql-mesh_graphql-8082-dependencies.md @@ -0,0 +1,9 @@ +--- +"@graphql-mesh/graphql": patch +--- +dependencies updates: + - Updated dependency [`@graphql-mesh/cross-helpers@^0.4.9` ↗︎](https://www.npmjs.com/package/@graphql-mesh/cross-helpers/v/0.4.9) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@graphql-mesh/store@^0.103.7` ↗︎](https://www.npmjs.com/package/@graphql-mesh/store/v/0.103.7) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@graphql-mesh/string-interpolation@^0.5.7` ↗︎](https://www.npmjs.com/package/@graphql-mesh/string-interpolation/v/0.5.7) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@graphql-mesh/types@^0.103.7` ↗︎](https://www.npmjs.com/package/@graphql-mesh/types/v/0.103.7) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@graphql-mesh/utils@^0.103.7` ↗︎](https://www.npmjs.com/package/@graphql-mesh/utils/v/0.103.7) (from `workspace:^`, in `dependencies`) diff --git a/.changeset/@graphql-mesh_plugin-operation-headers-8082-dependencies.md b/.changeset/@graphql-mesh_plugin-operation-headers-8082-dependencies.md new file mode 100644 index 0000000000000..81cc3a9a08577 --- /dev/null +++ b/.changeset/@graphql-mesh_plugin-operation-headers-8082-dependencies.md @@ -0,0 +1,6 @@ +--- +"@graphql-mesh/plugin-operation-headers": patch +--- +dependencies updates: + - Updated dependency [`@graphql-mesh/types@^0.103.7` ↗︎](https://www.npmjs.com/package/@graphql-mesh/types/v/0.103.7) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@graphql-mesh/utils@^0.103.7` ↗︎](https://www.npmjs.com/package/@graphql-mesh/utils/v/0.103.7) (from `workspace:^`, in `dependencies`) diff --git a/.changeset/@graphql-mesh_supergraph-8082-dependencies.md b/.changeset/@graphql-mesh_supergraph-8082-dependencies.md new file mode 100644 index 0000000000000..fe5693f010ede --- /dev/null +++ b/.changeset/@graphql-mesh_supergraph-8082-dependencies.md @@ -0,0 +1,9 @@ +--- +"@graphql-mesh/supergraph": patch +--- +dependencies updates: + - Updated dependency [`@graphql-mesh/cross-helpers@^0.4.9` ↗︎](https://www.npmjs.com/package/@graphql-mesh/cross-helpers/v/0.4.9) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@graphql-mesh/store@^0.103.7` ↗︎](https://www.npmjs.com/package/@graphql-mesh/store/v/0.103.7) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@graphql-mesh/string-interpolation@^0.5.7` ↗︎](https://www.npmjs.com/package/@graphql-mesh/string-interpolation/v/0.5.7) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@graphql-mesh/types@^0.103.7` ↗︎](https://www.npmjs.com/package/@graphql-mesh/types/v/0.103.7) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@graphql-mesh/utils@^0.103.7` ↗︎](https://www.npmjs.com/package/@graphql-mesh/utils/v/0.103.7) (from `workspace:^`, in `dependencies`) diff --git a/.changeset/@omnigraph_openapi-8082-dependencies.md b/.changeset/@omnigraph_openapi-8082-dependencies.md new file mode 100644 index 0000000000000..bd93d4d86f94b --- /dev/null +++ b/.changeset/@omnigraph_openapi-8082-dependencies.md @@ -0,0 +1,11 @@ +--- +"@omnigraph/openapi": patch +--- +dependencies updates: + - Updated dependency [`@graphql-mesh/cross-helpers@^0.4.9` ↗︎](https://www.npmjs.com/package/@graphql-mesh/cross-helpers/v/0.4.9) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@graphql-mesh/fusion-composition@^0.7.13` ↗︎](https://www.npmjs.com/package/@graphql-mesh/fusion-composition/v/0.7.13) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@graphql-mesh/string-interpolation@^0.5.7` ↗︎](https://www.npmjs.com/package/@graphql-mesh/string-interpolation/v/0.5.7) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@graphql-mesh/types@^0.103.7` ↗︎](https://www.npmjs.com/package/@graphql-mesh/types/v/0.103.7) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@graphql-mesh/utils@^0.103.7` ↗︎](https://www.npmjs.com/package/@graphql-mesh/utils/v/0.103.7) (from `workspace:^`, in `dependencies`) + - Updated dependency [`@omnigraph/json-schema@^0.108.7` ↗︎](https://www.npmjs.com/package/@omnigraph/json-schema/v/0.108.7) (from `workspace:^`, in `dependencies`) + - Updated dependency [`json-machete@^0.97.5` ↗︎](https://www.npmjs.com/package/json-machete/v/0.97.5) (from `workspace:^`, in `dependencies`) diff --git a/.changeset/twelve-tigers-applaud.md b/.changeset/twelve-tigers-applaud.md new file mode 100644 index 0000000000000..bfc5d29c68ac5 --- /dev/null +++ b/.changeset/twelve-tigers-applaud.md @@ -0,0 +1,10 @@ +--- +'@graphql-mesh/config': patch +'@graphql-mesh/cli': patch +'@graphql-mesh/include': patch +'@graphql-mesh/json-schema': patch +'@graphql-mesh/runtime': patch +'@graphql-mesh/utils': patch +--- + +Import enhancements diff --git a/babel.config.js b/babel.config.js index 04700458b918b..8e66f82bea090 100644 --- a/babel.config.js +++ b/babel.config.js @@ -6,5 +6,6 @@ module.exports = { plugins: [ '@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-explicit-resource-management', + '@babel/plugin-syntax-top-level-await', ], }; diff --git a/examples/federation-example/tests/polling.test.ts b/examples/federation-example/tests/polling.test.ts index 14853c0d3d725..b8873b4677ae5 100644 --- a/examples/federation-example/tests/polling.test.ts +++ b/examples/federation-example/tests/polling.test.ts @@ -40,12 +40,20 @@ describe('Polling Test', () => { SUPERGRAPH_SOURCE, }, }); + if (process.env.DEBUG) { + buildCmd.stderr?.on('data', function stderrListener(data: string) { + console.error(data); + }); + } await new Promise(resolve => { buildCmd.stdout?.on('data', function stdoutListener(data: string) { if (data.includes('Done!')) { buildCmd.stdout?.off('data', stdoutListener); resolve(); } + if (process.env.DEBUG) { + console.log(data); + } }); }); const port = await getAvailablePort(); @@ -57,6 +65,11 @@ describe('Polling Test', () => { SUPERGRAPH_SOURCE, }, }); + if (process.env.DEBUG) { + serveCmd.stderr?.on('data', function stderrListener(data: string) { + console.error(data); + }); + } await new Promise(resolve => { serveCmd.stdout?.on('data', function stdoutListener(data: string) { if (process.env.DEBUG) { @@ -70,13 +83,14 @@ describe('Polling Test', () => { }); const hostname = await getLocalHostName(port); const url = `http://${hostname}:${port}/graphql`; - const resp = await fetch(url, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - query: ` + await expect( + fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + query: ` { __type(name:"Query") { fields { @@ -85,10 +99,9 @@ describe('Polling Test', () => { } } `, - }), - }); - const data = await resp.json(); - expect(data).toEqual({ + }), + }).then(data => data.json()), + ).resolves.toEqual({ data: { __type: { fields: [ @@ -110,13 +123,14 @@ describe('Polling Test', () => { }); changedSupergraph = true; await new Promise(resolve => setTimeout(resolve, 3000)); - const resp2 = await fetch(url, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - query: ` + await expect( + fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + query: ` { __type(name:"Query") { fields { @@ -125,10 +139,9 @@ describe('Polling Test', () => { } } `, - }), - }); - const data2 = await resp2.json(); - expect(data2).toEqual({ + }), + }).then(data => data.json()), + ).resolves.toEqual({ data: { __type: { fields: [ diff --git a/examples/hello-world/.meshrc.yml b/examples/hello-world/.meshrc.yml index 9324bd79954b2..4a95702cd05c5 100644 --- a/examples/hello-world/.meshrc.yml +++ b/examples/hello-world/.meshrc.yml @@ -17,3 +17,6 @@ documents: query HelloWorld { greeting } + +serve: + playground: true diff --git a/examples/persisted-operations/tests/persisted-queries.test.ts b/examples/persisted-operations/tests/persisted-queries.test.ts index f9be18baf3036..2c1b913996963 100644 --- a/examples/persisted-operations/tests/persisted-queries.test.ts +++ b/examples/persisted-operations/tests/persisted-queries.test.ts @@ -31,7 +31,7 @@ describe('Persisted Queries', () => { }); }); - afterAll(() => mesh.destroy()); + afterAll(() => mesh?.destroy()); it('should give correct response for inline persisted operation', async () => { const response = await meshHttp.fetch('/graphql', { diff --git a/examples/programmatic-batching/tests/programmatic-batching.spec.ts b/examples/programmatic-batching/tests/programmatic-batching.spec.ts index 3eea33180992a..25ef87d06c3b7 100644 --- a/examples/programmatic-batching/tests/programmatic-batching.spec.ts +++ b/examples/programmatic-batching/tests/programmatic-batching.spec.ts @@ -5,6 +5,7 @@ import { findAndParseConfig } from '@graphql-mesh/cli'; import { ProcessedConfig } from '@graphql-mesh/config'; import { getMesh, MeshInstance } from '@graphql-mesh/runtime'; import { printSchemaWithDirectives } from '@graphql-tools/utils'; +import { dummyLogger } from '../../../packages/testing/dummyLogger'; import { createApp } from '../example-api/app'; describe('Batching Example', () => { @@ -15,14 +16,7 @@ describe('Batching Example', () => { dir: join(__dirname, '..'), }); const app = createApp(); - config.logger = { - info: () => {}, - error: () => {}, - warn: () => {}, - debug: () => {}, - log: () => {}, - child: () => config.logger, - }; + config.logger = dummyLogger; config.fetchFn = jest.fn(async (url, options) => app.fetch(url, options)); mesh = await getMesh(config); }); diff --git a/package.json b/package.json index 2d60e91944ebf..40980394fa6dd 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "prettier": "prettier --write --list-different .", "prettier:check": "prettier --check .", "release": "yarn build && changeset publish", - "test": "cross-env \"JEST=1\" jest --detectOpenHandles --no-watchman", + "test": "cross-env \"JEST=1\" jest --forceExit --no-watchman", "test:e2e": "cross-env \"JEST=1\" \"E2E_TEST=true\" jest --no-watchman --forceExit", "test:integration": "cross-env \"JEST=1\" \"INTEGRATION_TEST=true\" jest --forceExit --no-watchman", "test:integration:leak": "cross-env \"JEST=1\" \"LEAK_TEST=1\" \"INTEGRATION_TEST=true\" jest --detectOpenHandles --detectLeaks --no-watchman", @@ -69,6 +69,7 @@ "@babel/core": "7.26.0", "@babel/plugin-proposal-class-properties": "7.18.6", "@babel/plugin-proposal-explicit-resource-management": "7.25.9", + "@babel/plugin-syntax-top-level-await": "7.14.5", "@babel/preset-env": "7.26.0", "@babel/preset-typescript": "7.26.0", "@changesets/changelog-github": "0.5.0", diff --git a/packages/cache/redis/__integration_tests__/redis.spec.ts b/packages/cache/redis/__integration_tests__/redis.spec.ts index 1bacb4f53c255..852fc40d7918d 100644 --- a/packages/cache/redis/__integration_tests__/redis.spec.ts +++ b/packages/cache/redis/__integration_tests__/redis.spec.ts @@ -1,20 +1,12 @@ import RedisCache from '@graphql-mesh/cache-redis'; -import type { Logger } from '@graphql-mesh/types'; +import { dummyLogger } from '../../../testing/dummyLogger'; describe('Redis', () => { - const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, - }; it('works', async () => { using redisCache = new RedisCache({ host: '{env.REDIS_HOST}', port: '{env.REDIS_PORT}', - logger, + logger: dummyLogger, }); const test = await redisCache.get('test'); expect(test).toBeUndefined(); diff --git a/packages/cache/redis/test/cache.spec.ts b/packages/cache/redis/test/cache.spec.ts index a151d9d764971..f61ee925e66f5 100644 --- a/packages/cache/redis/test/cache.spec.ts +++ b/packages/cache/redis/test/cache.spec.ts @@ -1,20 +1,12 @@ /* eslint-disable no-new */ import Redis from 'ioredis'; -import type { Logger } from '@graphql-mesh/types'; +import { dummyLogger as logger } from '../../../testing/dummyLogger'; import RedisCache from '../src/index.js'; jest.mock('ioredis'); describe('redis', () => { beforeEach(() => jest.clearAllMocks()); - const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, - }; describe('constructor', () => { let redisUrlEnv: string; diff --git a/packages/compose-cli/package.json b/packages/compose-cli/package.json index 1cf756012e433..e0ffb5b006c0d 100644 --- a/packages/compose-cli/package.json +++ b/packages/compose-cli/package.json @@ -39,11 +39,11 @@ }, "dependencies": { "@commander-js/extra-typings": "^12.1.0", - "@graphql-mesh/fusion-composition": "workspace:^", - "@graphql-mesh/include": "workspace:^", - "@graphql-mesh/string-interpolation": "workspace:^", - "@graphql-mesh/types": "workspace:^", - "@graphql-mesh/utils": "workspace:^", + "@graphql-mesh/fusion-composition": "^0.7.13", + "@graphql-mesh/include": "^0.2.6", + "@graphql-mesh/string-interpolation": "^0.5.7", + "@graphql-mesh/types": "^0.103.7", + "@graphql-mesh/utils": "^0.103.7", "@graphql-tools/code-file-loader": "^8.1.7", "@graphql-tools/graphql-file-loader": "^8.0.5", "@graphql-tools/load": "^8.0.1", diff --git a/packages/compose-cli/tests/loadGraphQLHTTPSubgraph.test.ts b/packages/compose-cli/tests/loadGraphQLHTTPSubgraph.test.ts index 50ed1a5505c99..ec536b9ef0c8b 100644 --- a/packages/compose-cli/tests/loadGraphQLHTTPSubgraph.test.ts +++ b/packages/compose-cli/tests/loadGraphQLHTTPSubgraph.test.ts @@ -5,18 +5,11 @@ import { introspectionFromSchema, printSchema, } from 'graphql'; -import type { Logger, MeshFetch } from '@graphql-mesh/types'; +import type { MeshFetch } from '@graphql-mesh/types'; import { fakePromise } from '@graphql-tools/utils'; +import { dummyLogger as logger } from '../../testing/dummyLogger'; import { loadGraphQLHTTPSubgraph } from '../src/loadGraphQLHTTPSubgraph'; -const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, -}; describe('loadGraphQLHTTPSubgraph', () => { it('respects schemaHeaders in introspection query', async () => { const fetchFn = jest.fn, Parameters>(() => diff --git a/packages/fusion/composition/tests/loaders.spec.ts b/packages/fusion/composition/tests/loaders.spec.ts index 559e4bbc658b5..9481c492affd0 100644 --- a/packages/fusion/composition/tests/loaders.spec.ts +++ b/packages/fusion/composition/tests/loaders.spec.ts @@ -1,18 +1,10 @@ import { OperationTypeNode } from 'graphql'; import { createGatewayRuntime, useCustomFetch } from '@graphql-hive/gateway-runtime'; -import type { Logger } from '@graphql-mesh/types'; import { loadJSONSchemaSubgraph } from '@omnigraph/json-schema'; +import { dummyLogger as logger } from '../../../testing/dummyLogger'; import { composeSubgraphs } from '../src/compose'; describe('Loaders', () => { - const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, - }; it('works', async () => { const loadedSubgraph = loadJSONSchemaSubgraph('TEST', { endpoint: 'http://localhost/my-test-api', diff --git a/packages/include/src/index.ts b/packages/include/src/index.ts index 988fb547bf32b..6f00bc3e8320f 100644 --- a/packages/include/src/index.ts +++ b/packages/include/src/index.ts @@ -14,6 +14,7 @@ const jiti = createJiti( '', { debug: !!process.env.DEBUG, + interopDefault: true, }, ); diff --git a/packages/legacy/cli/src/commands/ts-artifacts.ts b/packages/legacy/cli/src/commands/ts-artifacts.ts index c1c29a7df8977..e79e232d3e6f7 100644 --- a/packages/legacy/cli/src/commands/ts-artifacts.ts +++ b/packages/legacy/cli/src/commands/ts-artifacts.ts @@ -292,10 +292,10 @@ export async function generateTsArtifacts( plugin: async () => { const importCodes = new Set([ ...meshConfigImportCodes, - `import { getMesh, ExecuteMeshFn, SubscribeMeshFn, MeshContext as BaseMeshContext, MeshInstance } from '@graphql-mesh/runtime';`, + `import { getMesh, type ExecuteMeshFn, type SubscribeMeshFn, type MeshContext as BaseMeshContext, type MeshInstance } from '@graphql-mesh/runtime';`, `import { MeshStore, FsStoreStorageAdapter } from '@graphql-mesh/store';`, `import { path as pathModule } from '@graphql-mesh/cross-helpers';`, - `import { ImportFn } from '@graphql-mesh/types';`, + `import type { ImportFn } from '@graphql-mesh/types';`, ]); const results = await Promise.all( rawSources.map(async source => { @@ -344,7 +344,7 @@ ${BASEDIR_ASSIGNMENT_COMMENT} const importFn: ImportFn = (moduleId: string) => { const relativeModuleId = (pathModule.isAbsolute(moduleId) ? pathModule.relative(baseDir, moduleId) : moduleId).split('\\\\').join('/').replace(baseDir + '/', ''); switch(relativeModuleId) {${[...importedModulesSet] - .map((importedModuleName, importedModuleIndex) => { + .map(importedModuleName => { const importPathRelativeToBaseDir = pathModule .relative(baseDir, importedModuleName) .split('\\') @@ -360,11 +360,9 @@ const importFn: ImportFn = (moduleId: string) => { .join('/')}`; importPath = replaceTypeScriptExtension(importPath); } - const importIdentifier = `importedModule$${importedModuleIndex}`; - importCodes.add(`import * as ${importIdentifier} from ${JSON.stringify(importPath)};`); return ` case ${JSON.stringify(importPathRelativeToBaseDir)}: - return Promise.resolve(${importIdentifier}) as T; + return import(${JSON.stringify(importPath)}) as T; `; }) .join('')} diff --git a/packages/legacy/cli/test/cli.spec.ts b/packages/legacy/cli/test/cli.spec.ts index b77c479622079..a5a7e2818bcb8 100644 --- a/packages/legacy/cli/test/cli.spec.ts +++ b/packages/legacy/cli/test/cli.spec.ts @@ -21,7 +21,7 @@ describe('runtime', () => { const builtMesh = (await fs.promises.readFile(meshConfigPath)).toString(); // Check that the import of the main Mesh module has replaced the extension - expect(builtMesh).toMatch(/import \* as importedModule(.*) from ".*\/\.meshrc.js";/); + expect(builtMesh).toMatch(/import\(".*\/\.meshrc.js"\)/); // Case should stay the same expect(builtMesh).toMatch(/case "\.meshrc.ts":/); @@ -43,7 +43,7 @@ describe('runtime', () => { const builtMesh = (await fs.promises.readFile(meshConfigPath)).toString(); // Check that the import of the main Mesh module has kept the file's extension - expect(builtMesh).toMatch(/import \* as importedModule(.*) from ".*\/\.meshrc.js";/); + expect(builtMesh).toMatch(/import\(".*\/\.meshrc.js"\)/); // Check that the reference to the relative module in the "importFn" function has kept the file's extension expect(builtMesh).toMatch(/case "\.meshrc.js":/); diff --git a/packages/legacy/config/src/process.ts b/packages/legacy/config/src/process.ts index 3b7440b1d40b5..359bc3ea9f367 100644 --- a/packages/legacy/config/src/process.ts +++ b/packages/legacy/config/src/process.ts @@ -104,6 +104,7 @@ export async function processConfig( const importCodes = new Set([ `import type { GetMeshOptions } from '@graphql-mesh/runtime';`, `import type { YamlConfig } from '@graphql-mesh/types';`, + `import { defaultImportFn } from '@graphql-mesh/utils';`, ]); const codes = new Set([ `export const rawServeConfig: YamlConfig.Config['serve'] = ${JSON.stringify( @@ -134,7 +135,9 @@ export async function processConfig( importCode: pubsubImportCode, code: pubsubCode, } = await resolvePubSub(config.pubsub, importFn, dir, additionalPackagePrefixes); - importCodes.add(pubsubImportCode); + if (pubsubImportCode) { + importCodes.add(pubsubImportCode); + } codes.add(pubsubCode); const sourcesStore = rootStore.child('sources'); @@ -154,11 +157,7 @@ export async function processConfig( importCodes.add(loggerImportCode); codes.add(loggerCode); - const { - cache, - importCode: cacheImportCode, - code: cacheCode, - } = await resolveCache( + const { cache, code: cacheCode } = await resolveCache( config.cache, importFn, rootStore, @@ -167,14 +166,9 @@ export async function processConfig( logger, additionalPackagePrefixes, ); - importCodes.add(cacheImportCode); codes.add(cacheCode); - const { - fetchFn, - importCode: fetchFnImportCode, - code: fetchFnCode, - } = await resolveCustomFetch({ + const { fetchFn, code: fetchFnCode } = await resolveCustomFetch({ fetchConfig: config.customFetch, cache, importFn, @@ -182,12 +176,11 @@ export async function processConfig( additionalPackagePrefixes, }); - importCodes.add(fetchFnImportCode); codes.add(fetchFnCode); - importCodes.add(`import { MeshResolvedSource } from '@graphql-mesh/runtime';`); + importCodes.add(`import type { MeshResolvedSource } from '@graphql-mesh/runtime';`); codes.add(`const sources: MeshResolvedSource[] = [];`); - importCodes.add(`import { MeshTransform, MeshPlugin } from '@graphql-mesh/types';`); + importCodes.add(`import type { MeshTransform, MeshPlugin } from '@graphql-mesh/types';`); codes.add(`const transforms: MeshTransform[] = [];`); codes.add(`const additionalEnvelopPlugins: MeshPlugin[] = [];`); @@ -216,7 +209,9 @@ export async function processConfig( }).then(({ resolved: HandlerCtor, moduleName }) => { if (options.generateCode) { const handlerImportName = pascalCase(handlerName + '_Handler'); - importCodes.add(`import ${handlerImportName} from ${JSON.stringify(moduleName)}`); + codes.add( + `const ${handlerImportName} = await defaultImportFn(${JSON.stringify(moduleName)});`, + ); codes.add(`const ${handlerVariableName} = new ${handlerImportName}({ name: ${JSON.stringify(source.name)}, config: ${JSON.stringify(handlerConfig)}, @@ -254,8 +249,8 @@ export async function processConfig( if (options.generateCode) { const transformImportName = pascalCase(transformName + '_Transform'); - importCodes.add( - `import ${transformImportName} from ${JSON.stringify(moduleName)};`, + codes.add( + `const ${transformImportName} = await defaultImportFn(${JSON.stringify(moduleName)});`, ); codes.add(`${transformsVariableName}[${transformIndex}] = new ${transformImportName}({ apiName: ${JSON.stringify(source.name)}, @@ -340,7 +335,10 @@ export async function processConfig( if (ENVELOP_CORE_PLUGINS_MAP[pluginName] != null) { const { importName, moduleName, pluginFactory } = ENVELOP_CORE_PLUGINS_MAP[pluginName]; if (options.generateCode) { - importCodes.add(`import { ${importName} } from ${JSON.stringify(moduleName)};`); + const importProp = `[${JSON.stringify(importName)}]`; + codes.add( + `const ${importName} = await defaultImportFn(${JSON.stringify(moduleName)}).then(m => m?.${importProp});`, + ); codes.add( `additionalEnvelopPlugins[${pluginIndex}] = await ${importName}(${JSON.stringify( pluginConfig, @@ -367,8 +365,10 @@ export async function processConfig( if (typeof possiblePluginFactory === 'function') { pluginFactory = possiblePluginFactory; if (options.generateCode) { - const importName = pascalCase('use_' + pluginName); - importCodes.add(`import ${importName} from ${JSON.stringify(moduleName)};`); + const importName = camelCase('use_' + pluginName); + codes.add( + `const ${importName} = await defaultImportFn(${JSON.stringify(moduleName)});`, + ); codes.add(`additionalEnvelopPlugins[${pluginIndex}] = await ${importName}({ ...(${JSON.stringify(pluginConfig, null, 2)}), logger: logger.child(${JSON.stringify(pluginName)}), @@ -546,29 +546,29 @@ export async function processConfig( additionalPrefixes: additionalPackagePrefixes, }); + const mergerLoggerPrefix = `${mergerName}Merger`; if (options.generateCode) { - const mergerImportName = pascalCase(`${mergerName}Merger`); - importCodes.add(`import ${mergerImportName} from ${JSON.stringify(mergerModuleName)};`); - codes.add(`const merger = new(${mergerImportName} as any)({ + codes.add(`const Merger = await defaultImportFn(${JSON.stringify(mergerModuleName)});`); + codes.add(`const merger = new Merger({ cache, pubsub, - logger: logger.child('${mergerName}Merger'), - store: rootStore.child('${mergerName}Merger') + logger: logger.child(${JSON.stringify(mergerLoggerPrefix)}), + store: rootStore.child(${JSON.stringify(mergerLoggerPrefix)}) })`); } const merger = new Merger({ cache, pubsub, - logger: logger.child(`${mergerName}Merger`), - store: rootStore.child(`${mergerName}Merger`), + logger: logger.child(mergerLoggerPrefix), + store: rootStore.child(mergerLoggerPrefix), }); if (config.additionalEnvelopPlugins) { codes.add( - `const importedAdditionalEnvelopPlugins = await import(${JSON.stringify( + `const importedAdditionalEnvelopPlugins = await defaultImportFn(${JSON.stringify( pathModule.join('..', config.additionalEnvelopPlugins).split('\\').join('/'), - )}).then(m => m.default || m);`, + )});`, ); const importedAdditionalEnvelopPlugins = await importFn( pathModule.isAbsolute(config.additionalEnvelopPlugins) @@ -645,16 +645,17 @@ export async function processConfig( }), ); if (options.generateCode) { - importCodes.add( - `import { usePersistedOperations } from '@graphql-yoga/plugin-persisted-operations';`, - ); codes.add(`const documentHashMap = { ${[...documentHashMapCodes].join(',\n')} }`); + codes.add( + `const usePersistedOperations = await defaultImportFn('@graphql-yoga/plugin-persisted-operations').then(m => m?.usePersistedOperations);`, + ); codes.add(`additionalEnvelopPlugins.push(usePersistedOperations({ getPersistedOperation(key) { return documentHashMap[key]; }, + allowArbitraryOperations: true, ...${JSON.stringify(config.persistedOperations ?? {}, null, 2)} }))`); } diff --git a/packages/legacy/config/src/utils.ts b/packages/legacy/config/src/utils.ts index e0864e20c0810..14be955f605c7 100644 --- a/packages/legacy/config/src/utils.ts +++ b/packages/legacy/config/src/utils.ts @@ -115,16 +115,12 @@ export async function resolveCustomFetch({ cache: KeyValueCache; }): Promise<{ fetchFn: MeshFetch; - importCode: string; code: string; }> { - let importCode = ''; if (!fetchConfig) { - importCode += `import { fetch as fetchFn } from '@whatwg-node/fetch';\n`; return { fetchFn: defaultFetch, - importCode, - code: ``, + code: `const fetchFn = await defaultImportFn('@whatwg-node/fetch').then(m => m?.fetch || m);`, }; } const { moduleName, resolved: fetchFn } = await getPackage({ @@ -136,12 +132,11 @@ export async function resolveCustomFetch({ }); const processedModuleName = moduleName.startsWith('.') ? path.join('..', moduleName) : moduleName; - importCode += `import fetchFn from ${JSON.stringify(processedModuleName)};\n`; + const code = `const fetchFn = await defaultImportFn(${JSON.stringify(processedModuleName)}).then(m => m?.fetch || m);`; return { fetchFn, - importCode, - code: '', + code, }; } @@ -157,7 +152,6 @@ export async function resolveCache( additionalPackagePrefixes: string[], ): Promise<{ cache: KeyValueCache; - importCode: string; code: string; }> { const cacheName = Object.keys(cacheConfig)[0].toString(); @@ -179,18 +173,17 @@ export async function resolveCache( logger, }); - const code = `const cache = new (MeshCache as any)({ - ...(${JSON.stringify(config)} as any), + const code = `const MeshCache = await defaultImportFn(${JSON.stringify(moduleName)}); + const cache = new MeshCache({ + ...${JSON.stringify(config)}, importFn, store: rootStore.child('cache'), pubsub, logger, - } as any)`; - const importCode = `import MeshCache from ${JSON.stringify(moduleName)};`; + })`; return { cache, - importCode, code, }; } @@ -201,8 +194,8 @@ export async function resolvePubSub( cwd: string, additionalPackagePrefixes: string[], ): Promise<{ - importCode: string; code: string; + importCode: string; pubsub: MeshPubSub; }> { if (pubsubYamlConfig) { @@ -225,23 +218,22 @@ export async function resolvePubSub( const pubsub = new PubSub(pubsubConfig); - const importCode = `import PubSub from ${JSON.stringify(moduleName)}`; - const code = `const pubsub = new PubSub(${JSON.stringify(pubsubConfig)});`; + const code = `const PubSub = await defaultImportFn(${JSON.stringify(moduleName)}); + const pubsub = new PubSub(${JSON.stringify(pubsubConfig)});`; return { - importCode, code, + importCode: '', pubsub, }; } else { const pubsub = new PubSub(); - const importCode = `import { PubSub } from '@graphql-mesh/utils';`; const code = `const pubsub = new PubSub();`; return { - importCode, code, + importCode: `import { PubSub } from '@graphql-mesh/utils';`, pubsub, }; } @@ -287,8 +279,8 @@ export async function resolveLogger( return { logger, - importCode: `import logger from ${JSON.stringify(processedModuleName)};`, - code: '', + importCode: ``, + code: `const logger = await defaultImportFn(${JSON.stringify(processedModuleName)});`, }; } const logger = new DefaultLogger(initialLoggerPrefix); diff --git a/packages/legacy/config/test/processConfig.test.ts b/packages/legacy/config/test/processConfig.test.ts index 907832c63bb82..eb2387342560b 100644 --- a/packages/legacy/config/test/processConfig.test.ts +++ b/packages/legacy/config/test/processConfig.test.ts @@ -24,16 +24,16 @@ describe('processConfig', () => { let meshConfigContent = ''; // Find the custom fetch - const importCodesIterator = config.importCodes.values(); - let importCodesIteratorResult = importCodesIterator.next(); + const codesIterator = config.codes.values(); + let codesIteratorResult = codesIterator.next(); let includesCustomFetch; - while (!importCodesIteratorResult.done) { - if (importCodesIteratorResult.value.startsWith('import fetchFn from')) { - meshConfigContent = meshConfigContent.concat(importCodesIteratorResult.value, '\n'); + while (!codesIteratorResult.done) { + if (codesIteratorResult.value.startsWith('const fetchFn = await defaultImportFn(')) { + meshConfigContent = meshConfigContent.concat(codesIteratorResult.value, '\n'); includesCustomFetch = true; break; } - importCodesIteratorResult = importCodesIterator.next(); + codesIteratorResult = codesIterator.next(); } expect(includesCustomFetch).toBeTruthy(); @@ -42,6 +42,11 @@ describe('processConfig', () => { // Adding export of fetch function so its resolution is actually attempted meshConfigContent = meshConfigContent.concat('export { fetchFn };', '\n'); + meshConfigContent = meshConfigContent.replace('await defaultImportFn', 'fakeImport'); + meshConfigContent = + 'const fakeImport = m => require("@graphql-tools/utils").fakePromise(require(m));\n' + + meshConfigContent; + // Create a .ts file with the codes and importCodes content const meshConfigPath = pathModule.join(__dirname, generatedMeshConfiguration, '/index.ts'); await writeFile(meshConfigPath, meshConfigContent); diff --git a/packages/legacy/handlers/graphql/package.json b/packages/legacy/handlers/graphql/package.json index 6714e3ad62917..57bc7ecf5067b 100644 --- a/packages/legacy/handlers/graphql/package.json +++ b/packages/legacy/handlers/graphql/package.json @@ -35,11 +35,11 @@ "graphql": "*" }, "dependencies": { - "@graphql-mesh/cross-helpers": "workspace:^", - "@graphql-mesh/store": "workspace:^", - "@graphql-mesh/string-interpolation": "workspace:^", - "@graphql-mesh/types": "workspace:^", - "@graphql-mesh/utils": "workspace:^", + "@graphql-mesh/cross-helpers": "^0.4.9", + "@graphql-mesh/store": "^0.103.7", + "@graphql-mesh/string-interpolation": "^0.5.7", + "@graphql-mesh/types": "^0.103.7", + "@graphql-mesh/utils": "^0.103.7", "@graphql-tools/delegate": "^10.0.28", "@graphql-tools/federation": "^3.0.0", "@graphql-tools/merge": "^9.0.12", diff --git a/packages/legacy/handlers/graphql/test/handler.spec.ts b/packages/legacy/handlers/graphql/test/handler.spec.ts index 4f67b7edd1cbe..d9f4548416d9b 100644 --- a/packages/legacy/handlers/graphql/test/handler.spec.ts +++ b/packages/legacy/handlers/graphql/test/handler.spec.ts @@ -10,24 +10,15 @@ import { MeshStore, PredefinedProxyOptions, } from '@graphql-mesh/store'; -import type { Logger } from '@graphql-mesh/types'; import { defaultImportFn, PubSub } from '@graphql-mesh/utils'; import { printSchemaWithDirectives } from '@graphql-tools/utils'; import { fetch as fetchFn } from '@whatwg-node/fetch'; import { createDisposableServer } from '../../../../testing/createDisposableServer.js'; +import { dummyLogger as logger } from '../../../../testing/dummyLogger.js'; import GraphQLHandler from '../src/index.js'; const { readFile } = fsPromises; -const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, -}; - describe('graphql', () => { let store: MeshStore; using cache = new InMemoryLRUCache(); diff --git a/packages/legacy/handlers/grpc/test/handler.spec.ts b/packages/legacy/handlers/grpc/test/handler.spec.ts index 5ac2c46eba6b5..7f9c246f678fa 100644 --- a/packages/legacy/handlers/grpc/test/handler.spec.ts +++ b/packages/legacy/handlers/grpc/test/handler.spec.ts @@ -2,23 +2,15 @@ import { join } from 'path'; import { buildSchema, GraphQLSchema, validateSchema } from 'graphql'; import InMemoryLRUCache from '@graphql-mesh/cache-inmemory-lru'; import { InMemoryStoreStorageAdapter, MeshStore } from '@graphql-mesh/store'; -import type { KeyValueCache, Logger, YamlConfig } from '@graphql-mesh/types'; -import { defaultImportFn, DefaultLogger, PubSub } from '@graphql-mesh/utils'; +import type { KeyValueCache, YamlConfig } from '@graphql-mesh/types'; +import { defaultImportFn, PubSub } from '@graphql-mesh/utils'; import { printSchemaWithDirectives } from '@graphql-tools/utils'; -import { fetch as fetchFn } from '@whatwg-node/fetch'; +import { dummyLogger as logger } from '../../../../testing/dummyLogger'; import GrpcHandler from '../src/index.js'; describe('gRPC Handler', () => { let pubsub: PubSub; let store: MeshStore; - const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, - }; beforeEach(() => { pubsub = new PubSub(); store = new MeshStore('grpc-test', new InMemoryStoreStorageAdapter(), { diff --git a/packages/legacy/handlers/json-schema/src/index.ts b/packages/legacy/handlers/json-schema/src/index.ts index 0a92d68b4f654..4f56988de4e81 100644 --- a/packages/legacy/handlers/json-schema/src/index.ts +++ b/packages/legacy/handlers/json-schema/src/index.ts @@ -71,7 +71,7 @@ export default class JsonSchemaHandler implements MeshHandler { assumeValid: true, }); } - return this.schemaWithAnnotationsProxy.getWithSet(async () => { + return this.schemaWithAnnotationsProxy.getWithSet(() => { this.logger.info(`Generating GraphQL schema from JSON Schemas`); return loadNonExecutableGraphQLSchemaFromJSONSchemas(this.name, { ...this.config, diff --git a/packages/legacy/handlers/json-schema/test/handler.spec.ts b/packages/legacy/handlers/json-schema/test/handler.spec.ts index 6d21b72d3bac9..6e6df246e29fa 100644 --- a/packages/legacy/handlers/json-schema/test/handler.spec.ts +++ b/packages/legacy/handlers/json-schema/test/handler.spec.ts @@ -2,21 +2,13 @@ import { parse } from 'graphql'; import InMemoryLRUCache from '@graphql-mesh/cache-inmemory-lru'; import { InMemoryStoreStorageAdapter, MeshStore } from '@graphql-mesh/store'; -import type { Logger } from '@graphql-mesh/types'; import { defaultImportFn, getHeadersObj, PubSub } from '@graphql-mesh/utils'; import { normalizedExecutor } from '@graphql-tools/executor'; import { Headers, Response } from '@whatwg-node/fetch'; +import { dummyLogger as logger } from '../../../../testing/dummyLogger'; import JsonSchemaHandler from '../src/index.js'; describe('JSON Schema Handler', () => { - const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, - }; // TODO: Implement this feature later it.skip('should accept a code file for operationHeaders', async () => { const handler = new JsonSchemaHandler({ diff --git a/packages/legacy/handlers/odata/test/handler.spec.ts b/packages/legacy/handlers/odata/test/handler.spec.ts index 154876186c10a..64a36994bdec4 100644 --- a/packages/legacy/handlers/odata/test/handler.spec.ts +++ b/packages/legacy/handlers/odata/test/handler.spec.ts @@ -3,10 +3,11 @@ import { GraphQLInterfaceType, parse, type ExecutionResult } from 'graphql'; import InMemoryLRUCache from '@graphql-mesh/cache-inmemory-lru'; import { fs, path } from '@graphql-mesh/cross-helpers'; import { InMemoryStoreStorageAdapter, MeshStore } from '@graphql-mesh/store'; -import type { KeyValueCache, Logger, MeshPubSub } from '@graphql-mesh/types'; -import { DefaultLogger, PubSub } from '@graphql-mesh/utils'; +import type { KeyValueCache, MeshPubSub } from '@graphql-mesh/types'; +import { PubSub } from '@graphql-mesh/utils'; import { normalizedExecutor } from '@graphql-tools/executor'; import { printSchemaWithDirectives } from '@graphql-tools/utils'; +import { dummyLogger as logger } from '../../../../testing/dummyLogger.js'; import ODataHandler from '../src/index.js'; import { addMock, mockFetch, MockResponse, resetMocks } from './custom-fetch.js'; @@ -38,14 +39,6 @@ const importFn = (id: string) => require(id); describe('odata', () => { let pubsub: MeshPubSub; let store: MeshStore; - const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, - }; beforeEach(() => { pubsub = new PubSub(); store = new MeshStore('odata', new InMemoryStoreStorageAdapter(), { diff --git a/packages/legacy/handlers/supergraph/package.json b/packages/legacy/handlers/supergraph/package.json index d5bcc8207a65c..4c5c32a0d91da 100644 --- a/packages/legacy/handlers/supergraph/package.json +++ b/packages/legacy/handlers/supergraph/package.json @@ -35,11 +35,11 @@ "graphql": "*" }, "dependencies": { - "@graphql-mesh/cross-helpers": "workspace:^", - "@graphql-mesh/store": "workspace:^", - "@graphql-mesh/string-interpolation": "workspace:^", - "@graphql-mesh/types": "workspace:^", - "@graphql-mesh/utils": "workspace:^", + "@graphql-mesh/cross-helpers": "^0.4.9", + "@graphql-mesh/store": "^0.103.7", + "@graphql-mesh/string-interpolation": "^0.5.7", + "@graphql-mesh/types": "^0.103.7", + "@graphql-mesh/utils": "^0.103.7", "@graphql-tools/federation": "^3.0.0", "@graphql-tools/url-loader": "^8.0.9", "@graphql-tools/utils": "^10.6.0", diff --git a/packages/legacy/handlers/supergraph/tests/supergraph.spec.ts b/packages/legacy/handlers/supergraph/tests/supergraph.spec.ts index 462d5401a4310..52524aeb9aa6e 100644 --- a/packages/legacy/handlers/supergraph/tests/supergraph.spec.ts +++ b/packages/legacy/handlers/supergraph/tests/supergraph.spec.ts @@ -12,6 +12,7 @@ import type { MeshFetch } from '@graphql-mesh/types'; import { defaultImportFn as importFn, PubSub } from '@graphql-mesh/utils'; import { fetch as defaultFetchFn } from '@whatwg-node/fetch'; import { createDisposableServer } from '../../../../testing/createDisposableServer.js'; +import { dummyLogger as logger } from '../../../../testing/dummyLogger.js'; import { AUTH_HEADER as AUTHORS_AUTH_HEADER, server as authorsServer, @@ -24,16 +25,6 @@ import { describe('Supergraph', () => { let baseHandlerConfig; let baseGetMeshConfig; - const logger = { - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - log: jest.fn(), - child() { - return logger; - }, - }; const libcurl = globalThis.libcurl; beforeEach(() => { globalThis.libcurl = null; @@ -254,7 +245,7 @@ describe('Supergraph', () => { }), ).rejects.toThrow(); expect(logger.error.mock.calls[0][0].toString()) - .toBe(`Failed to generate the schema for the source "supergraph" + .toBe(`Failed to generate the schema for the source Supergraph source must be a valid GraphQL SDL string or a parsed DocumentNode, but got an invalid result from ./fixtures/supergraph-invalid.graphql instead. Got result: type Query { @@ -279,7 +270,7 @@ describe('Supergraph', () => { }), ).rejects.toThrow(); expect(logger.error.mock.calls[0][0].toString()) - .toBe(`Failed to generate the schema for the source "supergraph" + .toBe(`Failed to generate the schema for the source Failed to load supergraph SDL from http://down-sdl-source.com/my-sdl.graphql: getaddrinfo ENOTFOUND down-sdl-source.com`); }); diff --git a/packages/legacy/runtime/src/get-mesh.ts b/packages/legacy/runtime/src/get-mesh.ts index c93b1b4257b8a..e8a16e833d9df 100644 --- a/packages/legacy/runtime/src/get-mesh.ts +++ b/packages/legacy/runtime/src/get-mesh.ts @@ -204,9 +204,8 @@ export async function getMesh(options: GetMeshOptions): Promise { createProxyingResolver: createProxyingResolverFactory(apiName, rootTypeMap), }; } catch (e: any) { - sourceLogger.error( - `Failed to generate the schema for the source "${apiName}"\n ${e.message}`, - ); + sourceLogger.debug(e); + sourceLogger.error(`Failed to generate the schema for the source\n ${e.message}`); failed = true; } }), diff --git a/packages/legacy/runtime/test/getMesh.test.ts b/packages/legacy/runtime/test/getMesh.test.ts index 416b5f06a17c8..59468964f6109 100644 --- a/packages/legacy/runtime/test/getMesh.test.ts +++ b/packages/legacy/runtime/test/getMesh.test.ts @@ -6,10 +6,10 @@ import JsonSchemaHandler from '@graphql-mesh/json-schema'; import BareMerger from '@graphql-mesh/merger-bare'; import StitchingMerger from '@graphql-mesh/merger-stitching'; import { InMemoryStoreStorageAdapter, MeshStore } from '@graphql-mesh/store'; -import type { Logger } from '@graphql-mesh/types'; import { defaultImportFn, PubSub } from '@graphql-mesh/utils'; import { makeExecutableSchema } from '@graphql-tools/schema'; import { printSchemaWithDirectives } from '@graphql-tools/utils'; +import { dummyLogger as logger } from '../../../testing/dummyLogger'; import { getMesh } from '../src/get-mesh.js'; import type { MeshResolvedSource } from '../src/types.js'; @@ -18,7 +18,6 @@ describe('getMesh', () => { let cache: InMemoryLRUCache; let pubsub: PubSub; let store: MeshStore; - let logger: Logger; let merger: StitchingMerger; beforeEach(() => { cache = new InMemoryLRUCache(); @@ -27,14 +26,6 @@ describe('getMesh', () => { readonly: false, validate: false, }); - logger = { - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - log: jest.fn(), - child: () => logger, - }; merger = new StitchingMerger({ store, cache, diff --git a/packages/legacy/transforms/cache/test/cache.spec.ts b/packages/legacy/transforms/cache/test/cache.spec.ts index 41be6f5bd6cd1..51ff64589601c 100644 --- a/packages/legacy/transforms/cache/test/cache.spec.ts +++ b/packages/legacy/transforms/cache/test/cache.spec.ts @@ -11,26 +11,13 @@ import { } from 'graphql'; import InMemoryLRUCache from '@graphql-mesh/cache-inmemory-lru'; import { hashObject } from '@graphql-mesh/string-interpolation'; -import type { - ImportFn, - Logger, - MeshPubSub, - MeshTransformOptions, - YamlConfig, -} from '@graphql-mesh/types'; +import type { ImportFn, MeshPubSub, MeshTransformOptions, YamlConfig } from '@graphql-mesh/types'; import { PubSub } from '@graphql-mesh/utils'; import { addResolversToSchema, makeExecutableSchema } from '@graphql-tools/schema'; +import { dummyLogger as logger } from '../../../../testing/dummyLogger'; import { computeCacheKey } from '../src/compute-cache-key.js'; import CacheTransform from '../src/index.js'; -const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, -}; const wait = (seconds: number) => new Promise(resolve => setTimeout(resolve, seconds * 1000)); const importFn: ImportFn = m => import(m); diff --git a/packages/legacy/transforms/encapsulate/test/encapsulate.spec.ts b/packages/legacy/transforms/encapsulate/test/encapsulate.spec.ts index e3ee7a3ea17e5..96bc213ebfc5e 100644 --- a/packages/legacy/transforms/encapsulate/test/encapsulate.spec.ts +++ b/packages/legacy/transforms/encapsulate/test/encapsulate.spec.ts @@ -1,25 +1,17 @@ import { getIntrospectionQuery, parse } from 'graphql'; import { envelop, useEngine, useSchema } from '@envelop/core'; import InMemoryLRUCache from '@graphql-mesh/cache-inmemory-lru'; -import type { ImportFn, Logger, MeshPubSub } from '@graphql-mesh/types'; -import { DefaultLogger, PubSub } from '@graphql-mesh/utils'; -import { Subschema } from '@graphql-tools/delegate'; +import type { ImportFn, MeshPubSub } from '@graphql-mesh/types'; +import { PubSub } from '@graphql-mesh/utils'; import { normalizedExecutor } from '@graphql-tools/executor'; import { makeExecutableSchema } from '@graphql-tools/schema'; import { isAsyncIterable } from '@graphql-tools/utils'; import { wrapSchema } from '@graphql-tools/wrap'; import { Repeater } from '@repeaterjs/repeater'; +import { dummyLogger as logger } from '../../../../testing/dummyLogger'; import Transform from '../src/index.js'; describe('encapsulate', () => { - const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, - }; const baseDir: string = undefined; const importFn: ImportFn = m => import(m); const schema = makeExecutableSchema({ diff --git a/packages/legacy/transforms/federation/test/federation.spec.ts b/packages/legacy/transforms/federation/test/federation.spec.ts index 9c172df2c3477..dc61b47b50440 100644 --- a/packages/legacy/transforms/federation/test/federation.spec.ts +++ b/packages/legacy/transforms/federation/test/federation.spec.ts @@ -1,9 +1,9 @@ /* eslint-disable import/no-extraneous-dependencies */ import { buildSchema } from 'graphql'; import InMemoryLRUCache from '@graphql-mesh/cache-inmemory-lru'; -import type { Logger } from '@graphql-mesh/types'; -import { defaultImportFn, DefaultLogger, PubSub } from '@graphql-mesh/utils'; +import { defaultImportFn, PubSub } from '@graphql-mesh/utils'; import { printSchemaWithDirectives } from '@graphql-tools/utils'; +import { dummyLogger as logger } from '../../../../testing/dummyLogger'; import FederationTransform from '../src/index.js'; describe('transform-federation', () => { @@ -11,14 +11,7 @@ describe('transform-federation', () => { const baseDir = __dirname; const config = {}; const importFn = defaultImportFn; - const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, - }; + const cache = new InMemoryLRUCache(); const pubsub = new PubSub(); it('should trim non federation directives', () => { using cache = new InMemoryLRUCache(); diff --git a/packages/legacy/transforms/hoist-field/test/transform.spec.ts b/packages/legacy/transforms/hoist-field/test/transform.spec.ts index aed565f4537b7..e62003e529794 100644 --- a/packages/legacy/transforms/hoist-field/test/transform.spec.ts +++ b/packages/legacy/transforms/hoist-field/test/transform.spec.ts @@ -1,19 +1,12 @@ import { buildSchema, GraphQLObjectType, printSchema, type GraphQLField } from 'graphql'; import InMemoryLRUCache from '@graphql-mesh/cache-inmemory-lru'; import type { Logger, MeshPubSub } from '@graphql-mesh/types'; -import { defaultImportFn, DefaultLogger, PubSub } from '@graphql-mesh/utils'; +import { defaultImportFn, PubSub } from '@graphql-mesh/utils'; import { wrapSchema } from '@graphql-tools/wrap'; +import { dummyLogger as logger } from '../../../../testing/dummyLogger'; import HoistFieldTransform from '../src/index.js'; describe('hoist', () => { - const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, - }; const importFn = defaultImportFn; const schema = buildSchema(/* GraphQL */ ` type Query { diff --git a/packages/legacy/transforms/naming-convention/test/naming-convention.spec.ts b/packages/legacy/transforms/naming-convention/test/naming-convention.spec.ts index afbd33294bccb..592ec17603f8d 100644 --- a/packages/legacy/transforms/naming-convention/test/naming-convention.spec.ts +++ b/packages/legacy/transforms/naming-convention/test/naming-convention.spec.ts @@ -7,21 +7,14 @@ import { parse, } from 'graphql'; import InMemoryLRUCache from '@graphql-mesh/cache-inmemory-lru'; -import type { ImportFn, Logger, MeshPubSub } from '@graphql-mesh/types'; -import { DefaultLogger, PubSub } from '@graphql-mesh/utils'; +import type { ImportFn, MeshPubSub } from '@graphql-mesh/types'; +import { PubSub } from '@graphql-mesh/utils'; import { addResolversToSchema, makeExecutableSchema } from '@graphql-tools/schema'; import { printSchemaWithDirectives } from '@graphql-tools/utils'; +import { dummyLogger as logger } from '../../../../testing/dummyLogger'; import { describeTransformerTests } from '../../../testing/describeTransformerTests.js'; import NamingConventionTransform from '../src/index.js'; -const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, -}; describeTransformerTests('naming-convention', ({ mode, transformSchema }) => { const schema = buildSchema(/* GraphQL */ ` type Query { diff --git a/packages/legacy/transforms/prefix/test/prefix.spec.ts b/packages/legacy/transforms/prefix/test/prefix.spec.ts index 88f9aea0caf5d..515b21b990135 100644 --- a/packages/legacy/transforms/prefix/test/prefix.spec.ts +++ b/packages/legacy/transforms/prefix/test/prefix.spec.ts @@ -1,20 +1,13 @@ import { GraphQLObjectType, GraphQLSchema, parse, printSchema } from 'graphql'; import InMemoryLRUCache from '@graphql-mesh/cache-inmemory-lru'; import type { Logger, MeshPubSub } from '@graphql-mesh/types'; -import { DefaultLogger, PubSub } from '@graphql-mesh/utils'; +import { PubSub } from '@graphql-mesh/utils'; import { normalizedExecutor } from '@graphql-tools/executor'; import { makeExecutableSchema } from '@graphql-tools/schema'; +import { dummyLogger as logger } from '../../../../testing/dummyLogger'; import { describeTransformerTests } from '../../../testing/describeTransformerTests.js'; import PrefixTransform from '../src/index.js'; -const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, -}; describeTransformerTests('prefix', ({ mode, transformSchema }) => { let schema: GraphQLSchema; using cache = new InMemoryLRUCache(); diff --git a/packages/legacy/transforms/rate-limit/tests/rate-limit.spec.ts b/packages/legacy/transforms/rate-limit/tests/rate-limit.spec.ts index e8f8145aba67d..373f108ac017f 100644 --- a/packages/legacy/transforms/rate-limit/tests/rate-limit.spec.ts +++ b/packages/legacy/transforms/rate-limit/tests/rate-limit.spec.ts @@ -1,24 +1,17 @@ import { setTimeout } from 'timers/promises'; import { parse } from 'graphql'; import InMemoryLRUCache from '@graphql-mesh/cache-inmemory-lru'; -import type { Logger } from '@graphql-mesh/types'; -import { defaultImportFn, DefaultLogger, PubSub } from '@graphql-mesh/utils'; +import { defaultImportFn, PubSub } from '@graphql-mesh/utils'; import { normalizedExecutor } from '@graphql-tools/executor'; import { makeExecutableSchema } from '@graphql-tools/schema'; import { isAsyncIterable } from '@graphql-tools/utils'; import { wrapSchema } from '@graphql-tools/wrap'; +import { dummyLogger as logger } from '../../../../testing/dummyLogger'; import RateLimitTransform from '../src/index.js'; describe('Rate Limit Transform', () => { let pubsub: PubSub; - const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, - }; + let cache: InMemoryLRUCache; beforeEach(() => { pubsub = new PubSub(); diff --git a/packages/legacy/transforms/replace-field/test/replace-field.spec.ts b/packages/legacy/transforms/replace-field/test/replace-field.spec.ts index 4a4d68004a7b8..06f842833b215 100644 --- a/packages/legacy/transforms/replace-field/test/replace-field.spec.ts +++ b/packages/legacy/transforms/replace-field/test/replace-field.spec.ts @@ -6,6 +6,7 @@ import { PubSub } from '@graphql-mesh/utils'; import { normalizedExecutor } from '@graphql-tools/executor'; import { makeExecutableSchema } from '@graphql-tools/schema'; import { isAsyncIterable, pruneSchema } from '@graphql-tools/utils'; +import { dummyLogger as logger } from '../../../../testing/dummyLogger'; import ReplaceFieldTransform from '../src/index.js'; const importFn: ImportFn = m => @@ -15,14 +16,6 @@ const importFn: ImportFn = m => }); describe('replace-field', () => { - const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, - }; const mockQueryBooks = jest .fn() .mockImplementation(() => ({ books: [{ title: 'abc' }, { title: 'def' }] })); diff --git a/packages/legacy/transforms/resolvers-composition/test/transform.spec.ts b/packages/legacy/transforms/resolvers-composition/test/transform.spec.ts index d8494320eb1cf..80662d511f15a 100644 --- a/packages/legacy/transforms/resolvers-composition/test/transform.spec.ts +++ b/packages/legacy/transforms/resolvers-composition/test/transform.spec.ts @@ -1,22 +1,14 @@ import { join } from 'path'; import { parse } from 'graphql'; import InMemoryLRUCache from '@graphql-mesh/cache-inmemory-lru'; -import type { Logger } from '@graphql-mesh/types'; -import { DefaultLogger, PubSub } from '@graphql-mesh/utils'; +import { PubSub } from '@graphql-mesh/utils'; import { normalizedExecutor } from '@graphql-tools/executor'; import { makeExecutableSchema } from '@graphql-tools/schema'; import { isAsyncIterable } from '@graphql-tools/utils'; +import { dummyLogger as logger } from '../../../../testing/dummyLogger'; import ResolversCompositionTransform, { type ResolversComposition } from '../src/index.js'; describe('transform', () => { - const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, - }; const baseDir: string = undefined; using cache = new InMemoryLRUCache(); diff --git a/packages/legacy/transforms/transfer-schema/test/transfer-schema.spec.ts b/packages/legacy/transforms/transfer-schema/test/transfer-schema.spec.ts index b4fc0dfe935d1..441616eff7b83 100644 --- a/packages/legacy/transforms/transfer-schema/test/transfer-schema.spec.ts +++ b/packages/legacy/transforms/transfer-schema/test/transfer-schema.spec.ts @@ -2,8 +2,9 @@ import { GraphQLObjectType, printSchema } from 'graphql'; import InMemoryLRUCache from '@graphql-mesh/cache-inmemory-lru'; import type { Logger, MeshPubSub } from '@graphql-mesh/types'; -import { defaultImportFn, DefaultLogger, PubSub } from '@graphql-mesh/utils'; +import { defaultImportFn, PubSub } from '@graphql-mesh/utils'; import { makeExecutableSchema } from '@graphql-tools/schema'; +import { dummyLogger as logger } from '../../../../testing/dummyLogger'; import TransferFieldTransform from '../src/index.js'; describe('transfer-schema transform', () => { @@ -23,14 +24,6 @@ describe('transfer-schema transform', () => { } `; let pubsub: MeshPubSub; - const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, - }; const baseDir: string = undefined; using cache = new InMemoryLRUCache(); diff --git a/packages/legacy/utils/src/defaultImportFn.ts b/packages/legacy/utils/src/defaultImportFn.ts index 7dc4ca42e3c2b..d6d3e13276a2f 100644 --- a/packages/legacy/utils/src/defaultImportFn.ts +++ b/packages/legacy/utils/src/defaultImportFn.ts @@ -1,34 +1,39 @@ import { path as pathModule } from '@graphql-mesh/cross-helpers'; -async function defaultImportFn(path: string): Promise { - let module = await import(/* @vite-ignore */ path) - .catch(e => { +function defaultImportFn(path: string): Promise { + return import(/* @vite-ignore */ path).then( + module => { + let i = 0; + while (module?.default != null) { + if (i > 10 || module === module.default) { + break; + } + module = module.default; + i++; + } + if (typeof module === 'object' && module != null) { + const prototypeOfObject = Object.getPrototypeOf(module); + if (prototypeOfObject == null || prototypeOfObject === Object.prototype) { + const normalizedVal: Record = {}; + for (const key in module) { + normalizedVal[key] = module[key]; + } + return normalizedVal; + } + } + return module; + }, + e => { if (e.code === 'ERR_REQUIRE_ESM') { // eslint-disable-next-line no-new-func return new Function(`return import(${JSON.stringify(path)})`)(); } - throw e; - }) - .catch(e => { if (pathModule.isAbsolute(path) && !path.endsWith('.js') && !path.endsWith('.ts')) { return defaultImportFn(`${path}.ts`); } throw e; - }); - if (module.default != null) { - module = module.default; - } - if (typeof module === 'object' && module != null) { - const prototypeOfObject = Object.getPrototypeOf(module); - if (prototypeOfObject == null || prototypeOfObject === Object.prototype) { - const normalizedVal: Record = {}; - for (const key in module) { - normalizedVal[key] = module[key]; - } - return normalizedVal; - } - } - return module; + }, + ); } export { defaultImportFn }; diff --git a/packages/legacy/utils/test/read-file-or-url.spec.ts b/packages/legacy/utils/test/read-file-or-url.spec.ts index 419e37e00039d..288aa6fb602b9 100644 --- a/packages/legacy/utils/test/read-file-or-url.spec.ts +++ b/packages/legacy/utils/test/read-file-or-url.spec.ts @@ -1,20 +1,11 @@ import { writeFileSync } from 'fs'; import { tmpdir } from 'os'; import { join, relative } from 'path'; -import type { Logger } from '@graphql-mesh/types'; import { fetch } from '@whatwg-node/fetch'; -import { DefaultLogger } from '../src/logger.js'; +import { dummyLogger as logger } from '../../../testing/dummyLogger'; import { readFile } from '../src/read-file-or-url.js'; describe('readFile', () => { - const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, - }; it('should convert relative paths to absolute paths correctly', async () => { const tmpFileAbsolutePath = join(tmpdir(), './tmpfile.json'); const tmpFileContent = { diff --git a/packages/loaders/json-schema/test/getComposerFromSchema.test.ts b/packages/loaders/json-schema/test/getComposerFromSchema.test.ts index 6e53287c2945d..19ed3b3e2e99a 100644 --- a/packages/loaders/json-schema/test/getComposerFromSchema.test.ts +++ b/packages/loaders/json-schema/test/getComposerFromSchema.test.ts @@ -37,17 +37,10 @@ import { DefaultLogger, PubSub } from '@graphql-mesh/utils'; import { printSchemaWithDirectives } from '@graphql-tools/utils'; import type { JSONSchema } from '@json-schema-tools/meta-schema'; import { fetch } from '@whatwg-node/fetch'; +import { dummyLogger as logger } from '../../../testing/dummyLogger'; import { getComposerFromJSONSchema } from '../src/getComposerFromJSONSchema.js'; describe('getComposerFromJSONSchema', () => { - const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, - }; const pubsub = new PubSub() as MeshPubSub; it('should return JSON scalar if given schema is boolean true', async () => { const result = await getComposerFromJSONSchema({ subgraphName: 'Test', schema: true, logger }); diff --git a/packages/loaders/openapi/package.json b/packages/loaders/openapi/package.json index bff513bb521a7..8b84a09d0b8a4 100644 --- a/packages/loaders/openapi/package.json +++ b/packages/loaders/openapi/package.json @@ -35,16 +35,16 @@ "graphql": "*" }, "dependencies": { - "@graphql-mesh/cross-helpers": "workspace:^", - "@graphql-mesh/fusion-composition": "workspace:^", - "@graphql-mesh/string-interpolation": "workspace:^", - "@graphql-mesh/types": "workspace:^", - "@graphql-mesh/utils": "workspace:^", + "@graphql-mesh/cross-helpers": "^0.4.9", + "@graphql-mesh/fusion-composition": "^0.7.13", + "@graphql-mesh/string-interpolation": "^0.5.7", + "@graphql-mesh/types": "^0.103.7", + "@graphql-mesh/utils": "^0.103.7", "@graphql-tools/delegate": "^10.0.28", "@graphql-tools/utils": "10.6.2", - "@omnigraph/json-schema": "workspace:^", + "@omnigraph/json-schema": "^0.108.7", "change-case": "^4.1.2", - "json-machete": "workspace:^", + "json-machete": "^0.97.5", "openapi-types": "^12.1.0", "tslib": "^2.4.0" }, diff --git a/packages/loaders/soap/test/examples.test.ts b/packages/loaders/soap/test/examples.test.ts index a95b253ac69f6..3c0d3d8f061ff 100644 --- a/packages/loaders/soap/test/examples.test.ts +++ b/packages/loaders/soap/test/examples.test.ts @@ -2,8 +2,8 @@ import { promises } from 'fs'; import { join } from 'path'; import { printSchema } from 'graphql'; -import type { Logger } from '@graphql-mesh/types'; import { fetch } from '@whatwg-node/fetch'; +import { dummyLogger as logger } from '../../../testing/dummyLogger'; import { SOAPLoader } from '../src/index.js'; const { readFile } = promises; @@ -11,20 +11,12 @@ const { readFile } = promises; const examples = ['example1', 'example2', 'axis', 'greeting', 'tempconvert']; describe('Examples', () => { - const mockLogger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => mockLogger, - }; examples.forEach(example => { it(`should generate schema for ${example}`, async () => { const soapLoader = new SOAPLoader({ subgraphName: example, fetch, - logger: mockLogger, + logger, }); const example1Wsdl = await readFile( join(__dirname, './fixtures/' + example + '.wsdl'), diff --git a/packages/loaders/soap/test/soap.test.ts b/packages/loaders/soap/test/soap.test.ts index 867c971fc4696..276701c1580dd 100644 --- a/packages/loaders/soap/test/soap.test.ts +++ b/packages/loaders/soap/test/soap.test.ts @@ -6,19 +6,12 @@ import { parse } from 'graphql'; import type { Logger, MeshFetch } from '@graphql-mesh/types'; import { printSchemaWithDirectives } from '@graphql-tools/utils'; import { fetch } from '@whatwg-node/fetch'; +import { dummyLogger as logger } from '../../../testing/dummyLogger'; import { createExecutorFromSchemaAST, SOAPLoader } from '../src/index.js'; const { readFile } = promises; describe('SOAP Loader', () => { - const mockLogger: Logger = { - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - log: jest.fn(), - child: () => mockLogger, - }; afterEach(() => { globalAgent.destroy(); }); @@ -28,7 +21,7 @@ describe('SOAP Loader', () => { const soapLoader = new SOAPLoader({ subgraphName: 'Test', fetch, - logger: mockLogger, + logger, }); await soapLoader.fetchWSDL('https://www.crcind.com/csp/samples/SOAP.Demo.cls?WSDL'); const schema = soapLoader.buildSchema(); @@ -50,7 +43,7 @@ describe('SOAP Loader', () => { const soapLoader = new SOAPLoader({ subgraphName: 'Test', fetch, - logger: mockLogger, + logger, }); const example1Wsdl = await readFile(join(__dirname, './fixtures/greeting.wsdl'), 'utf8'); await soapLoader.loadWSDL(example1Wsdl); diff --git a/packages/plugins/newrelic/tests/newrelic.spec.ts b/packages/plugins/newrelic/tests/newrelic.spec.ts index 43f06b429a68d..98b72ad236465 100644 --- a/packages/plugins/newrelic/tests/newrelic.spec.ts +++ b/packages/plugins/newrelic/tests/newrelic.spec.ts @@ -3,28 +3,20 @@ import InMemoryLRUCache from '@graphql-mesh/cache-inmemory-lru'; import { createMeshHTTPHandler, type MeshHTTPHandler } from '@graphql-mesh/http'; import type { MeshInstance } from '@graphql-mesh/runtime'; -import type { Logger } from '@graphql-mesh/types'; -import { defaultImportFn, PubSub } from '@graphql-mesh/utils'; +import { defaultImportFn, DefaultLogger, PubSub } from '@graphql-mesh/utils'; import { TestAgent } from '@newrelic/test-utilities'; import { getTestMesh } from '../../../legacy/testing/getTestMesh.js'; +import { dummyLogger as logger } from '../../../testing/dummyLogger'; import useMeshNewRelic from '../src/index.js'; describe('New Relic', () => { let mesh: MeshInstance; let helper: any; let httpHandler: MeshHTTPHandler; + using cache = new InMemoryLRUCache(); + const pubsub = new PubSub(); + const baseDir = __dirname; beforeAll(async () => { - const logger: Logger = { - log: jest.fn(), - debug: jest.fn(), - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - child: () => logger, - }; - const cache = new InMemoryLRUCache(); - const pubsub = new PubSub(); - const baseDir = __dirname; helper = TestAgent.makeInstrumented(); mesh = await getTestMesh({ logger, diff --git a/packages/plugins/operation-headers/package.json b/packages/plugins/operation-headers/package.json index 98409fa819f3b..73e8068bc5aea 100644 --- a/packages/plugins/operation-headers/package.json +++ b/packages/plugins/operation-headers/package.json @@ -36,8 +36,8 @@ }, "dependencies": { "@graphql-hive/gateway-runtime": "^1.3.3", - "@graphql-mesh/types": "workspace:^", - "@graphql-mesh/utils": "workspace:^", + "@graphql-mesh/types": "^0.103.7", + "@graphql-mesh/utils": "^0.103.7", "tslib": "^2.4.0" }, "publishConfig": { diff --git a/packages/testing/dummyLogger.ts b/packages/testing/dummyLogger.ts new file mode 100644 index 0000000000000..d3f120214e099 --- /dev/null +++ b/packages/testing/dummyLogger.ts @@ -0,0 +1,10 @@ +import type { Logger } from '@graphql-mesh/types'; + +export const dummyLogger: jest.Mocked = { + log: jest.fn(), + debug: jest.fn(), + info: jest.fn(), + warn: jest.fn(), + error: jest.fn(), + child: (() => dummyLogger) as any, +}; diff --git a/yarn.lock b/yarn.lock index cbd364b6a449c..c3663c7244584 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1932,7 +1932,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-syntax-top-level-await@npm:^7.14.5": +"@babel/plugin-syntax-top-level-await@npm:7.14.5, @babel/plugin-syntax-top-level-await@npm:^7.14.5": version: 7.14.5 resolution: "@babel/plugin-syntax-top-level-await@npm:7.14.5" dependencies: @@ -6137,11 +6137,11 @@ __metadata: resolution: "@graphql-mesh/compose-cli@workspace:packages/compose-cli" dependencies: "@commander-js/extra-typings": "npm:^12.1.0" - "@graphql-mesh/fusion-composition": "workspace:^" - "@graphql-mesh/include": "workspace:^" - "@graphql-mesh/string-interpolation": "workspace:^" - "@graphql-mesh/types": "workspace:^" - "@graphql-mesh/utils": "workspace:^" + "@graphql-mesh/fusion-composition": "npm:^0.7.13" + "@graphql-mesh/include": "npm:^0.2.6" + "@graphql-mesh/string-interpolation": "npm:^0.5.7" + "@graphql-mesh/types": "npm:^0.103.7" + "@graphql-mesh/utils": "npm:^0.103.7" "@graphql-tools/code-file-loader": "npm:^8.1.7" "@graphql-tools/graphql-file-loader": "npm:^8.0.5" "@graphql-tools/load": "npm:^8.0.1" @@ -6185,7 +6185,7 @@ __metadata: languageName: unknown linkType: soft -"@graphql-mesh/cross-helpers@npm:^0.4.9, @graphql-mesh/cross-helpers@workspace:^, @graphql-mesh/cross-helpers@workspace:packages/cross-helpers": +"@graphql-mesh/cross-helpers@npm:^0.4.9, @graphql-mesh/cross-helpers@workspace:packages/cross-helpers": version: 0.0.0-use.local resolution: "@graphql-mesh/cross-helpers@workspace:packages/cross-helpers" dependencies: @@ -6196,7 +6196,7 @@ __metadata: languageName: unknown linkType: soft -"@graphql-mesh/fusion-composition@workspace:^, @graphql-mesh/fusion-composition@workspace:packages/fusion/composition": +"@graphql-mesh/fusion-composition@npm:^0.7.13, @graphql-mesh/fusion-composition@workspace:packages/fusion/composition": version: 0.0.0-use.local resolution: "@graphql-mesh/fusion-composition@workspace:packages/fusion/composition" dependencies: @@ -6251,11 +6251,11 @@ __metadata: version: 0.0.0-use.local resolution: "@graphql-mesh/graphql@workspace:packages/legacy/handlers/graphql" dependencies: - "@graphql-mesh/cross-helpers": "workspace:^" - "@graphql-mesh/store": "workspace:^" - "@graphql-mesh/string-interpolation": "workspace:^" - "@graphql-mesh/types": "workspace:^" - "@graphql-mesh/utils": "workspace:^" + "@graphql-mesh/cross-helpers": "npm:^0.4.9" + "@graphql-mesh/store": "npm:^0.103.7" + "@graphql-mesh/string-interpolation": "npm:^0.5.7" + "@graphql-mesh/types": "npm:^0.103.7" + "@graphql-mesh/utils": "npm:^0.103.7" "@graphql-tools/delegate": "npm:^10.0.28" "@graphql-tools/federation": "npm:^3.0.0" "@graphql-tools/merge": "npm:^9.0.12" @@ -6322,7 +6322,7 @@ __metadata: languageName: unknown linkType: soft -"@graphql-mesh/include@npm:^0.2.3, @graphql-mesh/include@npm:^0.2.6, @graphql-mesh/include@workspace:^, @graphql-mesh/include@workspace:packages/include": +"@graphql-mesh/include@npm:^0.2.3, @graphql-mesh/include@npm:^0.2.6, @graphql-mesh/include@workspace:packages/include": version: 0.0.0-use.local resolution: "@graphql-mesh/include@workspace:packages/include" dependencies: @@ -6678,8 +6678,8 @@ __metadata: resolution: "@graphql-mesh/plugin-operation-headers@workspace:packages/plugins/operation-headers" dependencies: "@graphql-hive/gateway-runtime": "npm:^1.3.3" - "@graphql-mesh/types": "workspace:^" - "@graphql-mesh/utils": "workspace:^" + "@graphql-mesh/types": "npm:^0.103.7" + "@graphql-mesh/utils": "npm:^0.103.7" tslib: "npm:^2.4.0" peerDependencies: graphql: "*" @@ -6848,7 +6848,7 @@ __metadata: languageName: unknown linkType: soft -"@graphql-mesh/store@npm:^0.103.7, @graphql-mesh/store@workspace:^, @graphql-mesh/store@workspace:packages/legacy/store": +"@graphql-mesh/store@npm:^0.103.7, @graphql-mesh/store@workspace:packages/legacy/store": version: 0.0.0-use.local resolution: "@graphql-mesh/store@workspace:packages/legacy/store" dependencies: @@ -6864,7 +6864,7 @@ __metadata: languageName: unknown linkType: soft -"@graphql-mesh/string-interpolation@npm:0.5.7, @graphql-mesh/string-interpolation@npm:^0.5.6, @graphql-mesh/string-interpolation@npm:^0.5.7, @graphql-mesh/string-interpolation@workspace:^, @graphql-mesh/string-interpolation@workspace:packages/string-interpolation": +"@graphql-mesh/string-interpolation@npm:0.5.7, @graphql-mesh/string-interpolation@npm:^0.5.6, @graphql-mesh/string-interpolation@npm:^0.5.7, @graphql-mesh/string-interpolation@workspace:packages/string-interpolation": version: 0.0.0-use.local resolution: "@graphql-mesh/string-interpolation@workspace:packages/string-interpolation" dependencies: @@ -6881,11 +6881,11 @@ __metadata: version: 0.0.0-use.local resolution: "@graphql-mesh/supergraph@workspace:packages/legacy/handlers/supergraph" dependencies: - "@graphql-mesh/cross-helpers": "workspace:^" - "@graphql-mesh/store": "workspace:^" - "@graphql-mesh/string-interpolation": "workspace:^" - "@graphql-mesh/types": "workspace:^" - "@graphql-mesh/utils": "workspace:^" + "@graphql-mesh/cross-helpers": "npm:^0.4.9" + "@graphql-mesh/store": "npm:^0.103.7" + "@graphql-mesh/string-interpolation": "npm:^0.5.7" + "@graphql-mesh/types": "npm:^0.103.7" + "@graphql-mesh/utils": "npm:^0.103.7" "@graphql-tools/federation": "npm:^3.0.0" "@graphql-tools/url-loader": "npm:^8.0.9" "@graphql-tools/utils": "npm:^10.6.0" @@ -7414,7 +7414,7 @@ __metadata: languageName: unknown linkType: soft -"@graphql-mesh/types@npm:^0.103.6, @graphql-mesh/types@npm:^0.103.7, @graphql-mesh/types@workspace:^, @graphql-mesh/types@workspace:packages/legacy/types": +"@graphql-mesh/types@npm:^0.103.6, @graphql-mesh/types@npm:^0.103.7, @graphql-mesh/types@workspace:packages/legacy/types": version: 0.0.0-use.local resolution: "@graphql-mesh/types@workspace:packages/legacy/types" dependencies: @@ -7444,7 +7444,7 @@ __metadata: languageName: unknown linkType: soft -"@graphql-mesh/utils@npm:^0.103.6, @graphql-mesh/utils@npm:^0.103.7, @graphql-mesh/utils@workspace:^, @graphql-mesh/utils@workspace:packages/legacy/utils": +"@graphql-mesh/utils@npm:^0.103.6, @graphql-mesh/utils@npm:^0.103.7, @graphql-mesh/utils@workspace:packages/legacy/utils": version: 0.0.0-use.local resolution: "@graphql-mesh/utils@workspace:packages/legacy/utils" dependencies: @@ -10138,7 +10138,7 @@ __metadata: languageName: unknown linkType: soft -"@omnigraph/json-schema@npm:0.108.7, @omnigraph/json-schema@workspace:*, @omnigraph/json-schema@workspace:^, @omnigraph/json-schema@workspace:packages/loaders/json-schema": +"@omnigraph/json-schema@npm:0.108.7, @omnigraph/json-schema@npm:^0.108.7, @omnigraph/json-schema@workspace:*, @omnigraph/json-schema@workspace:^, @omnigraph/json-schema@workspace:packages/loaders/json-schema": version: 0.0.0-use.local resolution: "@omnigraph/json-schema@workspace:packages/loaders/json-schema" dependencies: @@ -10243,20 +10243,20 @@ __metadata: version: 0.0.0-use.local resolution: "@omnigraph/openapi@workspace:packages/loaders/openapi" dependencies: - "@graphql-mesh/cross-helpers": "workspace:^" - "@graphql-mesh/fusion-composition": "workspace:^" - "@graphql-mesh/string-interpolation": "workspace:^" - "@graphql-mesh/types": "workspace:^" - "@graphql-mesh/utils": "workspace:^" + "@graphql-mesh/cross-helpers": "npm:^0.4.9" + "@graphql-mesh/fusion-composition": "npm:^0.7.13" + "@graphql-mesh/string-interpolation": "npm:^0.5.7" + "@graphql-mesh/types": "npm:^0.103.7" + "@graphql-mesh/utils": "npm:^0.103.7" "@graphql-tools/delegate": "npm:^10.0.28" "@graphql-tools/utils": "npm:10.6.2" - "@omnigraph/json-schema": "workspace:^" + "@omnigraph/json-schema": "npm:^0.108.7" "@whatwg-node/fetch": "npm:0.10.1" change-case: "npm:^4.1.2" fets: "npm:0.8.4" graphql-yoga: "npm:5.10.4" json-bigint-patch: "npm:0.0.8" - json-machete: "workspace:^" + json-machete: "npm:^0.97.5" openapi-types: "npm:^12.1.0" tslib: "npm:^2.4.0" peerDependencies: @@ -21820,6 +21820,7 @@ __metadata: "@babel/core": "npm:7.26.0" "@babel/plugin-proposal-class-properties": "npm:7.18.6" "@babel/plugin-proposal-explicit-resource-management": "npm:7.25.9" + "@babel/plugin-syntax-top-level-await": "npm:7.14.5" "@babel/preset-env": "npm:7.26.0" "@babel/preset-typescript": "npm:7.26.0" "@changesets/changelog-github": "npm:0.5.0" @@ -25145,7 +25146,7 @@ __metadata: languageName: node linkType: hard -"json-machete@npm:0.97.5, json-machete@workspace:^, json-machete@workspace:packages/json-machete": +"json-machete@npm:0.97.5, json-machete@npm:^0.97.5, json-machete@workspace:packages/json-machete": version: 0.0.0-use.local resolution: "json-machete@workspace:packages/json-machete" dependencies: