From f5700138bb42c08c033fda31fbb0b66d5e2cab94 Mon Sep 17 00:00:00 2001 From: Eddy Nguyen Date: Mon, 7 Apr 2025 23:30:40 +1000 Subject: [PATCH 01/10] Handle errors instead of swallowing them when ignoreNoDocuments=true --- .changeset/lazy-snails-fold.md | 5 + packages/graphql-codegen-cli/src/codegen.ts | 3 +- packages/graphql-codegen-cli/src/load.ts | 8 +- .../tests/generate-and-save.spec.ts | 109 +++++++++++++++--- .../tests/test-files/graphql.config.json | 14 --- .../graphql.config.no-doc-ignored.js | 16 +++ .../tests/test-files/graphql.config.no-doc.js | 15 +++ yarn.lock | 32 ++--- 8 files changed, 151 insertions(+), 51 deletions(-) create mode 100644 .changeset/lazy-snails-fold.md delete mode 100644 packages/graphql-codegen-cli/tests/test-files/graphql.config.json create mode 100644 packages/graphql-codegen-cli/tests/test-files/graphql.config.no-doc-ignored.js create mode 100644 packages/graphql-codegen-cli/tests/test-files/graphql.config.no-doc.js diff --git a/.changeset/lazy-snails-fold.md b/.changeset/lazy-snails-fold.md new file mode 100644 index 00000000000..532f4619641 --- /dev/null +++ b/.changeset/lazy-snails-fold.md @@ -0,0 +1,5 @@ +--- +'@graphql-codegen/cli': patch +--- + +Fix ignoreNoDocuments=true swallowing all errors diff --git a/packages/graphql-codegen-cli/src/codegen.ts b/packages/graphql-codegen-cli/src/codegen.ts index 6468e6e1b9a..10eaaa953d0 100644 --- a/packages/graphql-codegen-cli/src/codegen.ts +++ b/packages/graphql-codegen-cli/src/codegen.ts @@ -11,6 +11,7 @@ import { normalizeOutputParam, Types, } from '@graphql-codegen/plugin-helpers'; +import { NoTypeDefinitionsFound } from '@graphql-tools/load'; import { DocumentNode, GraphQLError, GraphQLSchema } from 'graphql'; import { Listr, ListrTask } from 'listr2'; import { CodegenContext, ensureContext, shouldEmitLegacyCommonJSImports } from './config.js'; @@ -279,7 +280,7 @@ export async function executeCodegen(input: CodegenContext | Types.Config): Prom documents, }; } catch (error) { - if (config.ignoreNoDocuments) { + if (error instanceof NoTypeDefinitionsFound && config.ignoreNoDocuments) { return { documents: [], }; diff --git a/packages/graphql-codegen-cli/src/load.ts b/packages/graphql-codegen-cli/src/load.ts index 24d9813f77e..74e97685a7d 100644 --- a/packages/graphql-codegen-cli/src/load.ts +++ b/packages/graphql-codegen-cli/src/load.ts @@ -9,6 +9,7 @@ import { JsonFileLoader } from '@graphql-tools/json-file-loader'; import { loadDocuments as loadDocumentsToolkit, loadSchema as loadSchemaToolkit, + NoTypeDefinitionsFound, UnnormalizedTypeDefPointer, } from '@graphql-tools/load'; import { PrismaLoader } from '@graphql-tools/prisma-loader'; @@ -101,7 +102,12 @@ export async function loadDocuments( }); return loadedFromToolkit; } catch (error) { - if (config.ignoreNoDocuments) return []; + // NoTypeDefinitionsFound from `@graphql-tools/load` already has a message with pointer, so we can just rethrow the error + if (error instanceof NoTypeDefinitionsFound) { + throw error; + } + + // For other errors, we need to add an error message with documentPointers, so it's better for DevX throw new Error( [`Failed to load documents from ${Object.keys(documentPointers).join(',')}:`, printError(error)].join('\n') ); diff --git a/packages/graphql-codegen-cli/tests/generate-and-save.spec.ts b/packages/graphql-codegen-cli/tests/generate-and-save.spec.ts index a1c01ad3a66..a9415905b05 100644 --- a/packages/graphql-codegen-cli/tests/generate-and-save.spec.ts +++ b/packages/graphql-codegen-cli/tests/generate-and-save.spec.ts @@ -77,22 +77,6 @@ describe('generate-and-save', () => { expect(writeSpy).not.toHaveBeenCalled(); }); - test('should not error when ignoreNoDocuments config option is present', async () => { - jest.spyOn(fs, 'writeFile').mockImplementation(); - const config = await createContext({ - config: './tests/test-files/graphql.config.json', - project: undefined, - errorsOnly: true, - overwrite: true, - profile: true, - require: [], - silent: false, - watch: false, - }); - - await generate(config, false); - }); - test('should use global overwrite option and write a file', async () => { const filename = 'overwrite.ts'; const writeSpy = jest.spyOn(fs, 'writeFile').mockImplementation(); @@ -255,11 +239,11 @@ describe('generate-and-save', () => { expect(writeSpy).toHaveBeenCalled(); }); - describe('Syntax errors when loading pointers', () => { + describe('Errors when loading pointers', () => { const originalConsole = { ...console }; const originalNodeEnv = process.env.NODE_ENV; - let consoleErrorMock; + let consoleErrorMock: jest.Mock; beforeEach(() => { // Mock common console functions to avoid noise in the terminal @@ -279,7 +263,8 @@ describe('generate-and-save', () => { process.env.NODE_ENV = originalNodeEnv; }); - test('Schema syntax error - should print native GraphQLError for', async () => { + test('Schema syntax error - should print native GraphQLError', async () => { + expect.assertions(4); try { await generate( { @@ -324,6 +309,7 @@ describe('generate-and-save', () => { }); test('Document syntax error - should print native GraphQLError', async () => { + expect.assertions(4); try { await generate( { @@ -352,5 +338,90 @@ describe('generate-and-save', () => { `); } }); + + test('No documents found - should throw error by default', async () => { + expect.assertions(1); + try { + await generate( + { + verbose: true, + schema: './tests/test-files/schema-dir/schema.ts', + documents: './tests/test-files/document-file-does-not-exist.graphql', + generates: { + 'src/test.ts': { + plugins: ['typescript'], + }, + }, + }, + false + ); + } catch { + expect(consoleErrorMock.mock.calls[0][0]).toBeSimilarStringTo(` + [FAILED] Unable to find any GraphQL type definitions for the following pointers: + [FAILED] + [FAILED] - ./tests/test-files/document-file-does-not-exist.graphql + `); + } + }); + + test('No documents found - should not fail if ignoreNoDocuments=true', async () => { + await generate( + { + verbose: true, + ignoreNoDocuments: true, + schema: './tests/test-files/schema-dir/schema.ts', + documents: './tests/test-files/document-file-does-not-exist.graphql', + generates: { + 'src/test.ts': { + plugins: ['typescript'], + }, + }, + }, + false + ); + expect(consoleErrorMock).not.toHaveBeenCalled(); + }); + + test('No documents found - GraphQL Config - should throw error by default', async () => { + expect.assertions(1); + try { + const config = await createContext({ + config: './tests/test-files/graphql.config.no-doc.js', + project: undefined, + errorsOnly: true, + overwrite: true, + profile: true, + require: [], + silent: false, + watch: false, + }); + + await generate(config, false); + } catch { + expect(consoleErrorMock.mock.calls[0][0]).toBeSimilarStringTo(` + [FAILED] + [FAILED] Unable to find any GraphQL type definitions for the following pointers: + [FAILED] + [FAILED] - ../test-documents/empty.graphql + `); + } + }); + test('No documents found - GraphQL Config - should not fail if ignoreNoDocuments=true', async () => { + jest.spyOn(fs, 'writeFile').mockImplementation(); + const config = await createContext({ + config: './tests/test-files/graphql.config.no-doc-ignored.js', + project: undefined, + errorsOnly: true, + overwrite: true, + profile: true, + require: [], + silent: false, + watch: false, + }); + + await generate(config, false); + + expect(consoleErrorMock).not.toHaveBeenCalled(); + }); }); }); diff --git a/packages/graphql-codegen-cli/tests/test-files/graphql.config.json b/packages/graphql-codegen-cli/tests/test-files/graphql.config.json deleted file mode 100644 index 0ac1eb49059..00000000000 --- a/packages/graphql-codegen-cli/tests/test-files/graphql.config.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "schema": ["../test-documents/schema.graphql"], - "documents": ["../test-documents/empty.graphql"], - "extensions": { - "codegen": { - "ignoreNoDocuments": true, - "generates": { - "./gql/": { - "preset": "client" - } - } - } - } -} diff --git a/packages/graphql-codegen-cli/tests/test-files/graphql.config.no-doc-ignored.js b/packages/graphql-codegen-cli/tests/test-files/graphql.config.no-doc-ignored.js new file mode 100644 index 00000000000..910ee88790f --- /dev/null +++ b/packages/graphql-codegen-cli/tests/test-files/graphql.config.no-doc-ignored.js @@ -0,0 +1,16 @@ +/** @type {import('graphql-config').IGraphQLConfig } */ +module.exports = { + schema: ['../test-documents/schema.graphql'], + documents: ['../test-documents/empty.graphql'], + extensions: { + codegen: { + verbose: true, + ignoreNoDocuments: true, + generates: { + './gql/': { + preset: 'client', + }, + }, + }, + }, +}; diff --git a/packages/graphql-codegen-cli/tests/test-files/graphql.config.no-doc.js b/packages/graphql-codegen-cli/tests/test-files/graphql.config.no-doc.js new file mode 100644 index 00000000000..1197e52b9a1 --- /dev/null +++ b/packages/graphql-codegen-cli/tests/test-files/graphql.config.no-doc.js @@ -0,0 +1,15 @@ +/** @type {import('graphql-config').IGraphQLConfig } */ +module.exports = { + schema: ['../test-documents/schema.graphql'], + documents: ['../test-documents/empty.graphql'], + extensions: { + codegen: { + verbose: true, + generates: { + './gql/': { + preset: 'client', + }, + }, + }, + }, +}; diff --git a/yarn.lock b/yarn.lock index 478b7ac953e..30a4726b55a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4987,16 +4987,16 @@ resolved "https://registry.yarnpkg.com/@types/trusted-types/-/trusted-types-2.0.2.tgz#fc25ad9943bcac11cceb8168db4f275e0e72e756" integrity sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg== -"@types/unist@*", "@types/unist@^2.0.0", "@types/unist@^2.0.2": - version "2.0.10" - resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.10.tgz#04ffa7f406ab628f7f7e97ca23e290cd8ab15efc" - integrity sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA== - -"@types/unist@^3.0.0": +"@types/unist@*", "@types/unist@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@types/unist/-/unist-3.0.0.tgz#988ae8af1e5239e89f9fbb1ade4c935f4eeedf9a" integrity sha512-MFETx3tbTjE7Uk6vvnWINA/1iJ7LuMdO4fcq8UfF0pRbj01aGLduVvQcRyswuACJdpnHgg8E3rQLhaRdNEJS0w== +"@types/unist@^2.0.0", "@types/unist@^2.0.2": + version "2.0.10" + resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.10.tgz#04ffa7f406ab628f7f7e97ca23e290cd8ab15efc" + integrity sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA== + "@types/ws@^8.0.0": version "8.5.4" resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.4.tgz#bb10e36116d6e570dd943735f86c933c1587b8a5" @@ -7240,7 +7240,14 @@ debug@2.6.9: dependencies: ms "2.0.0" -debug@4, debug@4.3.6, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@^4.3.5, debug@^4.3.6, debug@~4.3.6: +debug@4, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@^4.3.5, debug@^4.3.6, debug@^4.3.7: + version "4.4.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a" + integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA== + dependencies: + ms "^2.1.3" + +debug@4.3.6, debug@~4.3.6: version "4.3.6" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b" integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg== @@ -7254,13 +7261,6 @@ debug@^3.1.0, debug@^3.2.7: dependencies: ms "^2.1.1" -debug@^4.3.7: - version "4.4.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a" - integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA== - dependencies: - ms "^2.1.3" - decamelize@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -15158,12 +15158,12 @@ tsconfig-paths@^3.15.0: minimist "^1.2.6" strip-bom "^3.0.0" -tslib@2.6.3, tslib@^2.0.0, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.3.1, tslib@^2.4.0, tslib@^2.5.0, tslib@^2.5.2, tslib@^2.6.1, tslib@^2.6.2, tslib@^2.6.3, tslib@~2.6.0: +tslib@2.6.3, tslib@~2.6.0: version "2.6.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0" integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ== -tslib@^2.7.0: +tslib@^2.0.0, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.3.1, tslib@^2.4.0, tslib@^2.5.0, tslib@^2.5.2, tslib@^2.6.1, tslib@^2.6.2, tslib@^2.6.3, tslib@^2.7.0: version "2.8.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== From d27414fc1de908b94180a7bd00cc0b4ef8b99c62 Mon Sep 17 00:00:00 2001 From: Eddy Nguyen Date: Tue, 15 Apr 2025 22:38:21 +1000 Subject: [PATCH 02/10] Revert yarn.lock --- README.md | 2 +- yarn.lock | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 823b7e7ece5..33247054706 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@
GraphQL Code Generator logo - Created by The Guild + Created by The Guild
diff --git a/yarn.lock b/yarn.lock index 30a4726b55a..478b7ac953e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4987,16 +4987,16 @@ resolved "https://registry.yarnpkg.com/@types/trusted-types/-/trusted-types-2.0.2.tgz#fc25ad9943bcac11cceb8168db4f275e0e72e756" integrity sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg== -"@types/unist@*", "@types/unist@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@types/unist/-/unist-3.0.0.tgz#988ae8af1e5239e89f9fbb1ade4c935f4eeedf9a" - integrity sha512-MFETx3tbTjE7Uk6vvnWINA/1iJ7LuMdO4fcq8UfF0pRbj01aGLduVvQcRyswuACJdpnHgg8E3rQLhaRdNEJS0w== - -"@types/unist@^2.0.0", "@types/unist@^2.0.2": +"@types/unist@*", "@types/unist@^2.0.0", "@types/unist@^2.0.2": version "2.0.10" resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.10.tgz#04ffa7f406ab628f7f7e97ca23e290cd8ab15efc" integrity sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA== +"@types/unist@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/unist/-/unist-3.0.0.tgz#988ae8af1e5239e89f9fbb1ade4c935f4eeedf9a" + integrity sha512-MFETx3tbTjE7Uk6vvnWINA/1iJ7LuMdO4fcq8UfF0pRbj01aGLduVvQcRyswuACJdpnHgg8E3rQLhaRdNEJS0w== + "@types/ws@^8.0.0": version "8.5.4" resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.4.tgz#bb10e36116d6e570dd943735f86c933c1587b8a5" @@ -7240,14 +7240,7 @@ debug@2.6.9: dependencies: ms "2.0.0" -debug@4, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@^4.3.5, debug@^4.3.6, debug@^4.3.7: - version "4.4.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a" - integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA== - dependencies: - ms "^2.1.3" - -debug@4.3.6, debug@~4.3.6: +debug@4, debug@4.3.6, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@^4.3.5, debug@^4.3.6, debug@~4.3.6: version "4.3.6" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b" integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg== @@ -7261,6 +7254,13 @@ debug@^3.1.0, debug@^3.2.7: dependencies: ms "^2.1.1" +debug@^4.3.7: + version "4.4.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a" + integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA== + dependencies: + ms "^2.1.3" + decamelize@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -15158,12 +15158,12 @@ tsconfig-paths@^3.15.0: minimist "^1.2.6" strip-bom "^3.0.0" -tslib@2.6.3, tslib@~2.6.0: +tslib@2.6.3, tslib@^2.0.0, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.3.1, tslib@^2.4.0, tslib@^2.5.0, tslib@^2.5.2, tslib@^2.6.1, tslib@^2.6.2, tslib@^2.6.3, tslib@~2.6.0: version "2.6.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0" integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ== -tslib@^2.0.0, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.3.1, tslib@^2.4.0, tslib@^2.5.0, tslib@^2.5.2, tslib@^2.6.1, tslib@^2.6.2, tslib@^2.6.3, tslib@^2.7.0: +tslib@^2.7.0: version "2.8.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== From d89a49a765d93513aede5311e7901d3940df4084 Mon Sep 17 00:00:00 2001 From: Eddy Nguyen Date: Tue, 15 Apr 2025 22:43:42 +1000 Subject: [PATCH 03/10] Bump packages --- examples/programmatic-typescript/package.json | 2 +- packages/graphql-codegen-cli/package.json | 4 +- yarn.lock | 110 +++++++++++------- 3 files changed, 73 insertions(+), 43 deletions(-) diff --git a/examples/programmatic-typescript/package.json b/examples/programmatic-typescript/package.json index b2be14cf8d1..036fab37500 100644 --- a/examples/programmatic-typescript/package.json +++ b/examples/programmatic-typescript/package.json @@ -17,7 +17,7 @@ "@graphql-codegen/typescript-operations": "4.6.0", "@graphql-codegen/typescript-resolvers": "4.5.0", "@graphql-tools/graphql-file-loader": "8.0.1", - "@graphql-tools/load": "8.0.2", + "@graphql-tools/load": "8.1.0", "@graphql-tools/schema": "10.0.6", "graphql": "16.9.0", "graphql-tag": "2.12.6", diff --git a/packages/graphql-codegen-cli/package.json b/packages/graphql-codegen-cli/package.json index e85c377012f..072cf9e022b 100644 --- a/packages/graphql-codegen-cli/package.json +++ b/packages/graphql-codegen-cli/package.json @@ -52,7 +52,7 @@ "@graphql-tools/github-loader": "^8.0.0", "@graphql-tools/graphql-file-loader": "^8.0.0", "@graphql-tools/json-file-loader": "^8.0.0", - "@graphql-tools/load": "^8.0.0", + "@graphql-tools/load": "^8.1.0", "@graphql-tools/prisma-loader": "^8.0.0", "@graphql-tools/url-loader": "^8.0.0", "@graphql-tools/utils": "^10.0.0", @@ -61,7 +61,7 @@ "cosmiconfig": "^8.1.3", "debounce": "^1.2.0", "detect-indent": "^6.0.0", - "graphql-config": "^5.1.1", + "graphql-config": "^5.1.4", "inquirer": "^8.0.0", "is-glob": "^4.0.1", "jiti": "^1.17.1", diff --git a/yarn.lock b/yarn.lock index 478b7ac953e..3d2f9b5d07b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2862,13 +2862,13 @@ tslib "^2.4.0" unixify "^1.0.0" -"@graphql-tools/load@8.0.2", "@graphql-tools/load@^8.0.0": - version "8.0.2" - resolved "https://registry.yarnpkg.com/@graphql-tools/load/-/load-8.0.2.tgz#47d9916bf96dea05df27f11b53812f4327d9b6d2" - integrity sha512-S+E/cmyVmJ3CuCNfDuNF2EyovTwdWfQScXv/2gmvJOti2rGD8jTt9GYVzXaxhblLivQR9sBUCNZu/w7j7aXUCA== +"@graphql-tools/load@8.1.0", "@graphql-tools/load@^8.1.0": + version "8.1.0" + resolved "https://registry.yarnpkg.com/@graphql-tools/load/-/load-8.1.0.tgz#4aa03f071a8777e314b10289b7d6097daaaf8783" + integrity sha512-OGfOm09VyXdNGJS/rLqZ6ztCiG2g6AMxhwtET8GZXTbnjptFc17GtKwJ3Jv5w7mjJ8dn0BHydvIuEKEUK4ciYw== dependencies: - "@graphql-tools/schema" "^10.0.3" - "@graphql-tools/utils" "^10.0.13" + "@graphql-tools/schema" "^10.0.23" + "@graphql-tools/utils" "^10.8.6" p-limit "3.1.0" tslib "^2.4.0" @@ -2882,7 +2882,7 @@ p-limit "3.1.0" tslib "^2.4.0" -"@graphql-tools/merge@9.0.6", "@graphql-tools/merge@^9.0.0", "@graphql-tools/merge@^9.0.6": +"@graphql-tools/merge@9.0.6": version "9.0.6" resolved "https://registry.yarnpkg.com/@graphql-tools/merge/-/merge-9.0.6.tgz#06d3268a46f268b380665fd6a73da609c1854ca3" integrity sha512-TmkzFTFVieHnqu9mPTF6RxAQltaprpDQnM5HMTPSyMLXnJGMTvdWejV0yORKj7DW1YSi791/sUnKf8HytepBFQ== @@ -2898,6 +2898,14 @@ "@graphql-tools/utils" "^9.2.1" tslib "^2.4.0" +"@graphql-tools/merge@^9.0.0", "@graphql-tools/merge@^9.0.24", "@graphql-tools/merge@^9.0.6": + version "9.0.24" + resolved "https://registry.yarnpkg.com/@graphql-tools/merge/-/merge-9.0.24.tgz#1f366e85588894cb496bd1c332be7665db143df2" + integrity sha512-NzWx/Afl/1qHT3Nm1bghGG2l4jub28AdvtG11PoUlmjcIjnFBJMv4vqL0qnxWe8A82peWo4/TkVdjJRLXwgGEw== + dependencies: + "@graphql-tools/utils" "^10.8.6" + tslib "^2.4.0" + "@graphql-tools/optimize@^1.3.0": version "1.4.0" resolved "https://registry.yarnpkg.com/@graphql-tools/optimize/-/optimize-1.4.0.tgz#20d6a9efa185ef8fc4af4fd409963e0907c6e112" @@ -2952,7 +2960,7 @@ "@graphql-tools/utils" "^10.0.13" tslib "^2.4.0" -"@graphql-tools/schema@10.0.6", "@graphql-tools/schema@^10.0.0", "@graphql-tools/schema@^10.0.3", "@graphql-tools/schema@^10.0.4": +"@graphql-tools/schema@10.0.6": version "10.0.6" resolved "https://registry.yarnpkg.com/@graphql-tools/schema/-/schema-10.0.6.tgz#48391195ea4557ef5b6f77950bcbf529dc5f4e7e" integrity sha512-EIJgPRGzpvDFEjVp+RF1zNNYIC36BYuIeZ514jFoJnI6IdxyVyIRDLx/ykgMdaa1pKQerpfdqDnsF4JnZoDHSQ== @@ -2962,6 +2970,15 @@ tslib "^2.4.0" value-or-promise "^1.0.12" +"@graphql-tools/schema@^10.0.0", "@graphql-tools/schema@^10.0.23", "@graphql-tools/schema@^10.0.3", "@graphql-tools/schema@^10.0.4": + version "10.0.23" + resolved "https://registry.yarnpkg.com/@graphql-tools/schema/-/schema-10.0.23.tgz#d8865e96f37a04ca43303d7024add7edbe0c5ed4" + integrity sha512-aEGVpd1PCuGEwqTXCStpEkmheTHNdMayiIKH1xDWqYp9i8yKv9FRDgkGrY4RD8TNxnf7iII+6KOBGaJ3ygH95A== + dependencies: + "@graphql-tools/merge" "^9.0.24" + "@graphql-tools/utils" "^10.8.6" + tslib "^2.4.0" + "@graphql-tools/schema@^9.0.18", "@graphql-tools/schema@^9.0.19": version "9.0.19" resolved "https://registry.yarnpkg.com/@graphql-tools/schema/-/schema-9.0.19.tgz#c4ad373b5e1b8a0cf365163435b7d236ebdd06e7" @@ -3010,14 +3027,15 @@ value-or-promise "^1.0.11" ws "^8.12.0" -"@graphql-tools/utils@^10.0.0", "@graphql-tools/utils@^10.0.13", "@graphql-tools/utils@^10.3.2", "@graphql-tools/utils@^10.3.4", "@graphql-tools/utils@^10.5.4": - version "10.5.4" - resolved "https://registry.yarnpkg.com/@graphql-tools/utils/-/utils-10.5.4.tgz#214d815632a774f2db56bcaf7cfbd615ef858078" - integrity sha512-XHnyCWSlg1ccsD8s0y6ugo5GZ5TpkTiFVNPSYms5G0s6Z/xTuSmiLBfeqgkfaCwLmLaQnRCmNDL2JRnqc2R5bQ== +"@graphql-tools/utils@^10.0.0", "@graphql-tools/utils@^10.0.13", "@graphql-tools/utils@^10.3.2", "@graphql-tools/utils@^10.3.4", "@graphql-tools/utils@^10.5.4", "@graphql-tools/utils@^10.8.6": + version "10.8.6" + resolved "https://registry.yarnpkg.com/@graphql-tools/utils/-/utils-10.8.6.tgz#69ef29e408a27919108b2b2227fe8b465acf9e5c" + integrity sha512-Alc9Vyg0oOsGhRapfL3xvqh1zV8nKoFUdtLhXX7Ki4nClaIJXckrA86j+uxEuG3ic6j4jlM1nvcWXRn/71AVLQ== dependencies: "@graphql-typed-document-node/core" "^3.1.1" + "@whatwg-node/promise-helpers" "^1.0.0" cross-inspect "1.0.1" - dset "^3.1.2" + dset "^3.1.4" tslib "^2.4.0" "@graphql-tools/utils@^8.8.0": @@ -4987,16 +5005,16 @@ resolved "https://registry.yarnpkg.com/@types/trusted-types/-/trusted-types-2.0.2.tgz#fc25ad9943bcac11cceb8168db4f275e0e72e756" integrity sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg== -"@types/unist@*", "@types/unist@^2.0.0", "@types/unist@^2.0.2": - version "2.0.10" - resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.10.tgz#04ffa7f406ab628f7f7e97ca23e290cd8ab15efc" - integrity sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA== - -"@types/unist@^3.0.0": +"@types/unist@*", "@types/unist@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@types/unist/-/unist-3.0.0.tgz#988ae8af1e5239e89f9fbb1ade4c935f4eeedf9a" integrity sha512-MFETx3tbTjE7Uk6vvnWINA/1iJ7LuMdO4fcq8UfF0pRbj01aGLduVvQcRyswuACJdpnHgg8E3rQLhaRdNEJS0w== +"@types/unist@^2.0.0", "@types/unist@^2.0.2": + version "2.0.10" + resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.10.tgz#04ffa7f406ab628f7f7e97ca23e290cd8ab15efc" + integrity sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA== + "@types/ws@^8.0.0": version "8.5.4" resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.4.tgz#bb10e36116d6e570dd943735f86c933c1587b8a5" @@ -5424,6 +5442,13 @@ busboy "^1.6.0" tslib "^2.6.3" +"@whatwg-node/promise-helpers@^1.0.0": + version "1.3.1" + resolved "https://registry.yarnpkg.com/@whatwg-node/promise-helpers/-/promise-helpers-1.3.1.tgz#65f1820fa652ddc1062aa0fe7456726e8676ea43" + integrity sha512-D+OwTEunoQhVHVToD80dPhfz9xgPLqJyEA3F5jCRM14A2u8tBBQVdZekqfqx6ZAfZ+POT4Hb0dn601UKMsvADw== + dependencies: + tslib "^2.6.3" + "@whatwg-node/server@^0.9.44": version "0.9.47" resolved "https://registry.yarnpkg.com/@whatwg-node/server/-/server-0.9.47.tgz#e11a0c441ca6d86f4f78c40c0ddf8159acb2e5f8" @@ -7240,7 +7265,14 @@ debug@2.6.9: dependencies: ms "2.0.0" -debug@4, debug@4.3.6, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@^4.3.5, debug@^4.3.6, debug@~4.3.6: +debug@4, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@^4.3.5, debug@^4.3.6, debug@^4.3.7: + version "4.4.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a" + integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA== + dependencies: + ms "^2.1.3" + +debug@4.3.6, debug@~4.3.6: version "4.3.6" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b" integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg== @@ -7254,13 +7286,6 @@ debug@^3.1.0, debug@^3.2.7: dependencies: ms "^2.1.1" -debug@^4.3.7: - version "4.4.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a" - integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA== - dependencies: - ms "^2.1.3" - decamelize@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -7457,10 +7482,10 @@ dotenv@^8.1.0: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.6.0.tgz#061af664d19f7f4d8fc6e4ff9b584ce237adcb8b" integrity sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g== -dset@^3.1.1, dset@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/dset/-/dset-3.1.2.tgz#89c436ca6450398396dc6538ea00abc0c54cd45a" - integrity sha512-g/M9sqy3oHe477Ar4voQxWtaPIFw1jTdKZuomOjhCcBx9nHUNn0pu6NopuFFrTh/TRZIKEj+76vLWFu9BNKk+Q== +dset@^3.1.1, dset@^3.1.2, dset@^3.1.4: + version "3.1.4" + resolved "https://registry.yarnpkg.com/dset/-/dset-3.1.4.tgz#f8eaf5f023f068a036d08cd07dc9ffb7d0065248" + integrity sha512-2QF/g9/zTaPDc3BjNcVTGoBbXBgYfMTTceLaYcFJ/W9kggFUkhxD/hMEeuLKbugyef9SqAx8cpgwlIP/jinUTA== duplexer@^0.1.2, duplexer@~0.1.1: version "0.1.2" @@ -9014,19 +9039,19 @@ graphql-config@^4.1.0: string-env-interpolation "1.0.1" tslib "^2.4.0" -graphql-config@^5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/graphql-config/-/graphql-config-5.1.1.tgz#d840f20228da5c1386695838d6eb03cb7f7cf138" - integrity sha512-5FZUkX6A+q/gDSTDMeUbODwPnR+8nRNlI5z/ohtEmaD+XFeAalkB0KrWZ6cI7rcYUG05g43dPe+BRNZccQ5rKQ== +graphql-config@^5.1.4: + version "5.1.4" + resolved "https://registry.yarnpkg.com/graphql-config/-/graphql-config-5.1.4.tgz#12bc808648cd14ce83b509592db842a294018189" + integrity sha512-ObdBeL3ycddHrNbFvhGZ12pK8jUzWvvyN2A+6ij3XrtLH/KrkXt+BboEAEgXmeUrTcD5RjJnz8IZu3Cgc/oX/w== dependencies: "@graphql-tools/graphql-file-loader" "^8.0.0" "@graphql-tools/json-file-loader" "^8.0.0" - "@graphql-tools/load" "^8.0.0" + "@graphql-tools/load" "^8.1.0" "@graphql-tools/merge" "^9.0.0" "@graphql-tools/url-loader" "^8.0.0" "@graphql-tools/utils" "^10.0.0" cosmiconfig "^9.0.0" - jiti "^1.18.2" + jiti "^2.0.0" minimatch "^10.0.0" string-env-interpolation "^1.0.1" tslib "^2.4.0" @@ -10580,11 +10605,16 @@ jiti@1.17.1: resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.17.1.tgz#264daa43ee89a03e8be28c3d712ccc4eb9f1e8ed" integrity sha512-NZIITw8uZQFuzQimqjUxIrIcEdxYDFIe/0xYfIlVXTkiBjjyBEvgasj5bb0/cHtPRD/NziPbT312sFrkI5ALpw== -jiti@^1.17.1, jiti@^1.18.2, jiti@^1.21.6: +jiti@^1.17.1, jiti@^1.21.6: version "1.21.7" resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.21.7.tgz#9dd81043424a3d28458b193d965f0d18a2300ba9" integrity sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A== +jiti@^2.0.0: + version "2.4.2" + resolved "https://registry.yarnpkg.com/jiti/-/jiti-2.4.2.tgz#d19b7732ebb6116b06e2038da74a55366faef560" + integrity sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A== + joi@^17.11.0: version "17.11.0" resolved "https://registry.yarnpkg.com/joi/-/joi-17.11.0.tgz#aa9da753578ec7720e6f0ca2c7046996ed04fc1a" @@ -15158,12 +15188,12 @@ tsconfig-paths@^3.15.0: minimist "^1.2.6" strip-bom "^3.0.0" -tslib@2.6.3, tslib@^2.0.0, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.3.1, tslib@^2.4.0, tslib@^2.5.0, tslib@^2.5.2, tslib@^2.6.1, tslib@^2.6.2, tslib@^2.6.3, tslib@~2.6.0: +tslib@2.6.3, tslib@~2.6.0: version "2.6.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0" integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ== -tslib@^2.7.0: +tslib@^2.0.0, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.3.1, tslib@^2.4.0, tslib@^2.5.0, tslib@^2.5.2, tslib@^2.6.1, tslib@^2.6.2, tslib@^2.6.3, tslib@^2.7.0: version "2.8.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== From bf45e2cdfdabf2fd1e73ab9027abab4ffa4b97f3 Mon Sep 17 00:00:00 2001 From: Eddy Nguyen Date: Wed, 16 Apr 2025 00:05:44 +1000 Subject: [PATCH 04/10] Fix yarn.lock --- yarn.lock | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/yarn.lock b/yarn.lock index 3d2f9b5d07b..d6fdf41f9e3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2754,15 +2754,16 @@ value-or-promise "^1.0.12" "@graphql-tools/executor@^1.2.1", "@graphql-tools/executor@^1.3.0": - version "1.3.1" - resolved "https://registry.yarnpkg.com/@graphql-tools/executor/-/executor-1.3.1.tgz#69de74932442a84017c49639e23e0202e169db60" - integrity sha512-tgJDdGf9SCAm64ofEMZdv925u6/J+eTmv36TGNLxgP2DpCJsZ6gnJ4A+0D28EazDXqJIvMiPd+3d+o3cCRCAnQ== + version "1.4.7" + resolved "https://registry.yarnpkg.com/@graphql-tools/executor/-/executor-1.4.7.tgz#86bf0b26f2add5b686ec96e866ee22d1b81f9b6b" + integrity sha512-U0nK9jzJRP9/9Izf1+0Gggd6K6RNRsheFo1gC/VWzfnsr0qjcOSS9qTjY0OTC5iTPt4tQ+W5Zpw/uc7mebI6aA== dependencies: - "@graphql-tools/utils" "^10.3.4" - "@graphql-typed-document-node/core" "3.2.0" + "@graphql-tools/utils" "^10.8.6" + "@graphql-typed-document-node/core" "^3.2.0" "@repeaterjs/repeater" "^3.0.4" + "@whatwg-node/disposablestack" "^0.0.6" + "@whatwg-node/promise-helpers" "^1.0.0" tslib "^2.4.0" - value-or-promise "^1.0.12" "@graphql-tools/git-loader@^8.0.0": version "8.0.7" @@ -3027,7 +3028,7 @@ value-or-promise "^1.0.11" ws "^8.12.0" -"@graphql-tools/utils@^10.0.0", "@graphql-tools/utils@^10.0.13", "@graphql-tools/utils@^10.3.2", "@graphql-tools/utils@^10.3.4", "@graphql-tools/utils@^10.5.4", "@graphql-tools/utils@^10.8.6": +"@graphql-tools/utils@^10.0.0", "@graphql-tools/utils@^10.0.13", "@graphql-tools/utils@^10.3.2", "@graphql-tools/utils@^10.5.4", "@graphql-tools/utils@^10.8.6": version "10.8.6" resolved "https://registry.yarnpkg.com/@graphql-tools/utils/-/utils-10.8.6.tgz#69ef29e408a27919108b2b2227fe8b465acf9e5c" integrity sha512-Alc9Vyg0oOsGhRapfL3xvqh1zV8nKoFUdtLhXX7Ki4nClaIJXckrA86j+uxEuG3ic6j4jlM1nvcWXRn/71AVLQ== @@ -5375,6 +5376,14 @@ dependencies: tslib "^2.6.3" +"@whatwg-node/disposablestack@^0.0.6": + version "0.0.6" + resolved "https://registry.yarnpkg.com/@whatwg-node/disposablestack/-/disposablestack-0.0.6.tgz#2064a1425ea66194def6df0c7a1851b6939c82bb" + integrity sha512-LOtTn+JgJvX8WfBVJtF08TGrdjuFzGJc4mkP8EdDI8ADbvO7kiexYep1o8dwnt0okb0jYclCDXF13xU7Ge4zSw== + dependencies: + "@whatwg-node/promise-helpers" "^1.0.0" + tslib "^2.6.3" + "@whatwg-node/events@^0.0.3": version "0.0.3" resolved "https://registry.yarnpkg.com/@whatwg-node/events/-/events-0.0.3.tgz#13a65dd4f5893f55280f766e29ae48074927acad" From 41abe2f6b0ea923aad1cf59ca0c9ebafb3b59b1a Mon Sep 17 00:00:00 2001 From: Eddy Nguyen Date: Wed, 16 Apr 2025 00:08:38 +1000 Subject: [PATCH 05/10] Revert formatting --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 33247054706..823b7e7ece5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ From f30a25e7ba0a6eb948442346b433fd47aa74e1db Mon Sep 17 00:00:00 2001 From: Eddy Nguyen Date: Tue, 29 Apr 2025 18:08:09 +1000 Subject: [PATCH 06/10] Fix graphql-config dep version --- packages/graphql-codegen-cli/package.json | 2 +- yarn.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/graphql-codegen-cli/package.json b/packages/graphql-codegen-cli/package.json index 072cf9e022b..a81f3ae74aa 100644 --- a/packages/graphql-codegen-cli/package.json +++ b/packages/graphql-codegen-cli/package.json @@ -61,7 +61,7 @@ "cosmiconfig": "^8.1.3", "debounce": "^1.2.0", "detect-indent": "^6.0.0", - "graphql-config": "^5.1.4", + "graphql-config": "^5.1.5", "inquirer": "^8.0.0", "is-glob": "^4.0.1", "jiti": "^1.17.1", diff --git a/yarn.lock b/yarn.lock index d6fdf41f9e3..3f33c9f1c53 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6791,7 +6791,7 @@ cose-base@^2.2.0: dependencies: layout-base "^2.0.0" -cosmiconfig@8.0.0, cosmiconfig@8.3.6, cosmiconfig@^7.0.0, cosmiconfig@^8.1.3, cosmiconfig@^9.0.0: +cosmiconfig@8.0.0, cosmiconfig@8.3.6, cosmiconfig@^7.0.0, cosmiconfig@^8.1.0, cosmiconfig@^8.1.3: version "8.3.6" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-8.3.6.tgz#060a2b871d66dba6c8538ea1118ba1ac16f5fae3" integrity sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA== @@ -9048,10 +9048,10 @@ graphql-config@^4.1.0: string-env-interpolation "1.0.1" tslib "^2.4.0" -graphql-config@^5.1.4: - version "5.1.4" - resolved "https://registry.yarnpkg.com/graphql-config/-/graphql-config-5.1.4.tgz#12bc808648cd14ce83b509592db842a294018189" - integrity sha512-ObdBeL3ycddHrNbFvhGZ12pK8jUzWvvyN2A+6ij3XrtLH/KrkXt+BboEAEgXmeUrTcD5RjJnz8IZu3Cgc/oX/w== +graphql-config@^5.1.5: + version "5.1.5" + resolved "https://registry.yarnpkg.com/graphql-config/-/graphql-config-5.1.5.tgz#34e0bfba88e74b6eefd889716a9378086f595f7f" + integrity sha512-mG2LL1HccpU8qg5ajLROgdsBzx/o2M6kgI3uAmoaXiSH9PCUbtIyLomLqUtCFaAeG2YCFsl0M5cfQ9rKmDoMVA== dependencies: "@graphql-tools/graphql-file-loader" "^8.0.0" "@graphql-tools/json-file-loader" "^8.0.0" @@ -9059,9 +9059,9 @@ graphql-config@^5.1.4: "@graphql-tools/merge" "^9.0.0" "@graphql-tools/url-loader" "^8.0.0" "@graphql-tools/utils" "^10.0.0" - cosmiconfig "^9.0.0" + cosmiconfig "^8.1.0" jiti "^2.0.0" - minimatch "^10.0.0" + minimatch "^9.0.5" string-env-interpolation "^1.0.1" tslib "^2.4.0" From ddfe03f9f90c804ebcd15e75fc742eb751ffbeea Mon Sep 17 00:00:00 2001 From: Eddy Nguyen Date: Wed, 30 Apr 2025 00:42:19 +1000 Subject: [PATCH 07/10] Format --- packages/graphql-codegen-cli/tests/generate-and-save.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/graphql-codegen-cli/tests/generate-and-save.spec.ts b/packages/graphql-codegen-cli/tests/generate-and-save.spec.ts index a9415905b05..31bbe324c52 100644 --- a/packages/graphql-codegen-cli/tests/generate-and-save.spec.ts +++ b/packages/graphql-codegen-cli/tests/generate-and-save.spec.ts @@ -406,6 +406,7 @@ describe('generate-and-save', () => { `); } }); + test('No documents found - GraphQL Config - should not fail if ignoreNoDocuments=true', async () => { jest.spyOn(fs, 'writeFile').mockImplementation(); const config = await createContext({ From 069f8839c7d058036ae4898064c71302d5cd5aa0 Mon Sep 17 00:00:00 2001 From: Eddy Nguyen Date: Wed, 30 Apr 2025 01:04:44 +1000 Subject: [PATCH 08/10] Try splitting graphql-config tests --- .../graphql-codegen-cli/tests/codegen.spec.ts | 3 +- .../generate-and-save.graphql-config.spec.ts | 77 +++++++++++++++++++ .../tests/generate-and-save.spec.ts | 44 ----------- 3 files changed, 79 insertions(+), 45 deletions(-) create mode 100644 packages/graphql-codegen-cli/tests/generate-and-save.graphql-config.spec.ts diff --git a/packages/graphql-codegen-cli/tests/codegen.spec.ts b/packages/graphql-codegen-cli/tests/codegen.spec.ts index 6c3f13b630d..dda9223fe33 100644 --- a/packages/graphql-codegen-cli/tests/codegen.spec.ts +++ b/packages/graphql-codegen-cli/tests/codegen.spec.ts @@ -1096,7 +1096,8 @@ describe('Codegen Executor', () => { } }); - it('Should generate documents output even if prj1/documents and prj1/extensions/codegen/generate/xxx/documents are both definded with the same glob files', async () => { + // FIXME: Node 16 and graphql-config integration does not work + it.skip('Should generate documents output even if prj1/documents and prj1/extensions/codegen/generate/xxx/documents are both definded with the same glob files', async () => { const prj1 = await createContext({ config: './tests/test-files/graphql.config.js', project: 'prj1', diff --git a/packages/graphql-codegen-cli/tests/generate-and-save.graphql-config.spec.ts b/packages/graphql-codegen-cli/tests/generate-and-save.graphql-config.spec.ts new file mode 100644 index 00000000000..f3b694e2d65 --- /dev/null +++ b/packages/graphql-codegen-cli/tests/generate-and-save.graphql-config.spec.ts @@ -0,0 +1,77 @@ +import { useMonorepo } from '@graphql-codegen/testing'; +import { generate } from '../src/generate-and-save.js'; +import { createContext } from '../src/config.js'; +import * as fs from '../src/utils/file-system.js'; + +const monorepo = useMonorepo({ dirname: __dirname }); + +describe('generate-and-save - GraphQL Config', () => { + monorepo.correctCWD(); + + const originalConsole = { ...console }; + const originalNodeEnv = process.env.NODE_ENV; + + let consoleErrorMock: jest.Mock; + + beforeEach(() => { + // Mock common console functions to avoid noise in the terminal + global.console.log = jest.fn(); + global.console.warn = jest.fn(); + global.console.error = jest.fn(); + + // By default, the NODE_ENV is set to 'test', and this is used to silent console errors. + // For these tests below, we want to see what's being logged out to console errors. + process.env.NODE_ENV = 'not_test_so_error'; + + consoleErrorMock = jest.mocked(global.console.error); + }); + + afterEach(() => { + jest.resetAllMocks(); + global.console = originalConsole; + process.env.NODE_ENV = originalNodeEnv; + }); + + test('No documents found - GraphQL Config - should throw error by default', async () => { + expect.assertions(1); + try { + const config = await createContext({ + config: './tests/test-files/graphql.config.no-doc.js', + project: undefined, + errorsOnly: true, + overwrite: true, + profile: true, + require: [], + silent: false, + watch: false, + }); + + await generate(config, false); + } catch { + expect(consoleErrorMock.mock.calls[0][0]).toBeSimilarStringTo(` + [FAILED] + [FAILED] Unable to find any GraphQL type definitions for the following pointers: + [FAILED] + [FAILED] - ../test-documents/empty.graphql + `); + } + }); + + test('No documents found - GraphQL Config - should not fail if ignoreNoDocuments=true', async () => { + jest.spyOn(fs, 'writeFile').mockImplementation(); + const config = await createContext({ + config: './tests/test-files/graphql.config.no-doc-ignored.js', + project: undefined, + errorsOnly: true, + overwrite: true, + profile: true, + require: [], + silent: false, + watch: false, + }); + + await generate(config, false); + + expect(consoleErrorMock).not.toHaveBeenCalled(); + }); +}); diff --git a/packages/graphql-codegen-cli/tests/generate-and-save.spec.ts b/packages/graphql-codegen-cli/tests/generate-and-save.spec.ts index 31bbe324c52..8e4a2617a4d 100644 --- a/packages/graphql-codegen-cli/tests/generate-and-save.spec.ts +++ b/packages/graphql-codegen-cli/tests/generate-and-save.spec.ts @@ -3,7 +3,6 @@ import { Types } from '@graphql-codegen/plugin-helpers'; import { useMonorepo } from '@graphql-codegen/testing'; import makeDir from 'make-dir'; import { generate } from '../src/generate-and-save.js'; -import { createContext } from '../src/config.js'; import * as fs from '../src/utils/file-system.js'; const SIMPLE_TEST_SCHEMA = `type MyType { f: String } type Query { f: String }`; @@ -381,48 +380,5 @@ describe('generate-and-save', () => { ); expect(consoleErrorMock).not.toHaveBeenCalled(); }); - - test('No documents found - GraphQL Config - should throw error by default', async () => { - expect.assertions(1); - try { - const config = await createContext({ - config: './tests/test-files/graphql.config.no-doc.js', - project: undefined, - errorsOnly: true, - overwrite: true, - profile: true, - require: [], - silent: false, - watch: false, - }); - - await generate(config, false); - } catch { - expect(consoleErrorMock.mock.calls[0][0]).toBeSimilarStringTo(` - [FAILED] - [FAILED] Unable to find any GraphQL type definitions for the following pointers: - [FAILED] - [FAILED] - ../test-documents/empty.graphql - `); - } - }); - - test('No documents found - GraphQL Config - should not fail if ignoreNoDocuments=true', async () => { - jest.spyOn(fs, 'writeFile').mockImplementation(); - const config = await createContext({ - config: './tests/test-files/graphql.config.no-doc-ignored.js', - project: undefined, - errorsOnly: true, - overwrite: true, - profile: true, - require: [], - silent: false, - watch: false, - }); - - await generate(config, false); - - expect(consoleErrorMock).not.toHaveBeenCalled(); - }); }); }); From 980f21dbb298ab35c94daa6200219102129e1d55 Mon Sep 17 00:00:00 2001 From: Eddy Nguyen Date: Fri, 2 May 2025 21:30:18 +1000 Subject: [PATCH 09/10] Revert graphql-config version bump --- packages/graphql-codegen-cli/package.json | 2 +- yarn.lock | 59 +++++++++++------------ 2 files changed, 28 insertions(+), 33 deletions(-) diff --git a/packages/graphql-codegen-cli/package.json b/packages/graphql-codegen-cli/package.json index a81f3ae74aa..ca28c1224a3 100644 --- a/packages/graphql-codegen-cli/package.json +++ b/packages/graphql-codegen-cli/package.json @@ -61,7 +61,7 @@ "cosmiconfig": "^8.1.3", "debounce": "^1.2.0", "detect-indent": "^6.0.0", - "graphql-config": "^5.1.5", + "graphql-config": "^5.1.1", "inquirer": "^8.0.0", "is-glob": "^4.0.1", "jiti": "^1.17.1", diff --git a/yarn.lock b/yarn.lock index 3f33c9f1c53..65044a471d7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2863,7 +2863,7 @@ tslib "^2.4.0" unixify "^1.0.0" -"@graphql-tools/load@8.1.0", "@graphql-tools/load@^8.1.0": +"@graphql-tools/load@8.1.0", "@graphql-tools/load@^8.0.0", "@graphql-tools/load@^8.1.0": version "8.1.0" resolved "https://registry.yarnpkg.com/@graphql-tools/load/-/load-8.1.0.tgz#4aa03f071a8777e314b10289b7d6097daaaf8783" integrity sha512-OGfOm09VyXdNGJS/rLqZ6ztCiG2g6AMxhwtET8GZXTbnjptFc17GtKwJ3Jv5w7mjJ8dn0BHydvIuEKEUK4ciYw== @@ -4033,13 +4033,13 @@ "@parcel/watcher-win32-x64" "2.4.1" "@peculiar/asn1-schema@^2.3.13", "@peculiar/asn1-schema@^2.3.8": - version "2.3.13" - resolved "https://registry.yarnpkg.com/@peculiar/asn1-schema/-/asn1-schema-2.3.13.tgz#ec8509cdcbc0da3abe73fd7e690556b57a61b8f4" - integrity sha512-3Xq3a01WkHRZL8X04Zsfg//mGaA21xlL4tlVn4v2xGT0JStiztATRkMwa5b+f/HXmY2smsiLXYK46Gwgzvfg3g== + version "2.3.15" + resolved "https://registry.yarnpkg.com/@peculiar/asn1-schema/-/asn1-schema-2.3.15.tgz#e926bfdeed51945a06f38be703499e7d8341a5d3" + integrity sha512-QPeD8UA8axQREpgR5UTAfu2mqQmm97oUqahDtNdBcfj3qAnoXzFdQW+aNf/tD2WVXF8Fhmftxoj0eMIT++gX2w== dependencies: asn1js "^3.0.5" - pvtsutils "^1.3.5" - tslib "^2.6.2" + pvtsutils "^1.3.6" + tslib "^2.8.1" "@peculiar/json-schema@^1.1.12": version "1.1.12" @@ -5796,13 +5796,13 @@ asn1@~0.2.3: safer-buffer "~2.1.0" asn1js@^3.0.5: - version "3.0.5" - resolved "https://registry.yarnpkg.com/asn1js/-/asn1js-3.0.5.tgz#5ea36820443dbefb51cc7f88a2ebb5b462114f38" - integrity sha512-FVnvrKJwpt9LP2lAMl8qZswRNm3T4q9CON+bxldk2iwk3FFpuwhx2FfinyitizWHsVYyaY+y5JzDR0rCMV5yTQ== + version "3.0.6" + resolved "https://registry.yarnpkg.com/asn1js/-/asn1js-3.0.6.tgz#53e002ebe00c5f7fd77c1c047c3557d7c04dce25" + integrity sha512-UOCGPYbl0tv8+006qks/dTgV9ajs97X2p0FAbyS2iyCRrmLSRolDaHdp+v/CLgnzHc3fVB+CwYiUmei7ndFcgA== dependencies: - pvtsutils "^1.3.2" + pvtsutils "^1.3.6" pvutils "^1.1.3" - tslib "^2.4.0" + tslib "^2.8.1" assert-plus@1.0.0, assert-plus@^1.0.0: version "1.0.0" @@ -6791,7 +6791,7 @@ cose-base@^2.2.0: dependencies: layout-base "^2.0.0" -cosmiconfig@8.0.0, cosmiconfig@8.3.6, cosmiconfig@^7.0.0, cosmiconfig@^8.1.0, cosmiconfig@^8.1.3: +cosmiconfig@8.0.0, cosmiconfig@8.3.6, cosmiconfig@^7.0.0, cosmiconfig@^8.1.3, cosmiconfig@^9.0.0: version "8.3.6" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-8.3.6.tgz#060a2b871d66dba6c8538ea1118ba1ac16f5fae3" integrity sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA== @@ -9048,20 +9048,20 @@ graphql-config@^4.1.0: string-env-interpolation "1.0.1" tslib "^2.4.0" -graphql-config@^5.1.5: - version "5.1.5" - resolved "https://registry.yarnpkg.com/graphql-config/-/graphql-config-5.1.5.tgz#34e0bfba88e74b6eefd889716a9378086f595f7f" - integrity sha512-mG2LL1HccpU8qg5ajLROgdsBzx/o2M6kgI3uAmoaXiSH9PCUbtIyLomLqUtCFaAeG2YCFsl0M5cfQ9rKmDoMVA== +graphql-config@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/graphql-config/-/graphql-config-5.1.1.tgz#d840f20228da5c1386695838d6eb03cb7f7cf138" + integrity sha512-5FZUkX6A+q/gDSTDMeUbODwPnR+8nRNlI5z/ohtEmaD+XFeAalkB0KrWZ6cI7rcYUG05g43dPe+BRNZccQ5rKQ== dependencies: "@graphql-tools/graphql-file-loader" "^8.0.0" "@graphql-tools/json-file-loader" "^8.0.0" - "@graphql-tools/load" "^8.1.0" + "@graphql-tools/load" "^8.0.0" "@graphql-tools/merge" "^9.0.0" "@graphql-tools/url-loader" "^8.0.0" "@graphql-tools/utils" "^10.0.0" - cosmiconfig "^8.1.0" - jiti "^2.0.0" - minimatch "^9.0.5" + cosmiconfig "^9.0.0" + jiti "^1.18.2" + minimatch "^10.0.0" string-env-interpolation "^1.0.1" tslib "^2.4.0" @@ -10614,16 +10614,11 @@ jiti@1.17.1: resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.17.1.tgz#264daa43ee89a03e8be28c3d712ccc4eb9f1e8ed" integrity sha512-NZIITw8uZQFuzQimqjUxIrIcEdxYDFIe/0xYfIlVXTkiBjjyBEvgasj5bb0/cHtPRD/NziPbT312sFrkI5ALpw== -jiti@^1.17.1, jiti@^1.21.6: +jiti@^1.17.1, jiti@^1.18.2, jiti@^1.21.6: version "1.21.7" resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.21.7.tgz#9dd81043424a3d28458b193d965f0d18a2300ba9" integrity sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A== -jiti@^2.0.0: - version "2.4.2" - resolved "https://registry.yarnpkg.com/jiti/-/jiti-2.4.2.tgz#d19b7732ebb6116b06e2038da74a55366faef560" - integrity sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A== - joi@^17.11.0: version "17.11.0" resolved "https://registry.yarnpkg.com/joi/-/joi-17.11.0.tgz#aa9da753578ec7720e6f0ca2c7046996ed04fc1a" @@ -13300,12 +13295,12 @@ punycode@^2.1.0: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== -pvtsutils@^1.3.2, pvtsutils@^1.3.5: - version "1.3.5" - resolved "https://registry.yarnpkg.com/pvtsutils/-/pvtsutils-1.3.5.tgz#b8705b437b7b134cd7fd858f025a23456f1ce910" - integrity sha512-ARvb14YB9Nm2Xi6nBq1ZX6dAM0FsJnuk+31aUp4TrcZEdKUlSqOqsxJHUPJDNE3qiIp+iUPEIeR6Je/tgV7zsA== +pvtsutils@^1.3.5, pvtsutils@^1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/pvtsutils/-/pvtsutils-1.3.6.tgz#ec46e34db7422b9e4fdc5490578c1883657d6001" + integrity sha512-PLgQXQ6H2FWCaeRak8vvk1GW462lMxB5s3Jm673N82zI4vqtVUPuZdffdZbPDFRoU8kAhItWFtPCWiPpp4/EDg== dependencies: - tslib "^2.6.1" + tslib "^2.8.1" pvutils@^1.1.3: version "1.1.3" @@ -15202,7 +15197,7 @@ tslib@2.6.3, tslib@~2.6.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0" integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ== -tslib@^2.0.0, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.3.1, tslib@^2.4.0, tslib@^2.5.0, tslib@^2.5.2, tslib@^2.6.1, tslib@^2.6.2, tslib@^2.6.3, tslib@^2.7.0: +tslib@^2.0.0, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.3.1, tslib@^2.4.0, tslib@^2.5.0, tslib@^2.5.2, tslib@^2.6.2, tslib@^2.6.3, tslib@^2.7.0, tslib@^2.8.1: version "2.8.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== From 60da34d73a34e0e564025094b103c5449f87e0bb Mon Sep 17 00:00:00 2001 From: Eddy Nguyen Date: Fri, 2 May 2025 21:34:37 +1000 Subject: [PATCH 10/10] Revert skipped and splitted tests --- .../graphql-codegen-cli/tests/codegen.spec.ts | 3 +- .../generate-and-save.graphql-config.spec.ts | 77 ------------------- .../tests/generate-and-save.spec.ts | 44 +++++++++++ 3 files changed, 45 insertions(+), 79 deletions(-) delete mode 100644 packages/graphql-codegen-cli/tests/generate-and-save.graphql-config.spec.ts diff --git a/packages/graphql-codegen-cli/tests/codegen.spec.ts b/packages/graphql-codegen-cli/tests/codegen.spec.ts index dda9223fe33..6c3f13b630d 100644 --- a/packages/graphql-codegen-cli/tests/codegen.spec.ts +++ b/packages/graphql-codegen-cli/tests/codegen.spec.ts @@ -1096,8 +1096,7 @@ describe('Codegen Executor', () => { } }); - // FIXME: Node 16 and graphql-config integration does not work - it.skip('Should generate documents output even if prj1/documents and prj1/extensions/codegen/generate/xxx/documents are both definded with the same glob files', async () => { + it('Should generate documents output even if prj1/documents and prj1/extensions/codegen/generate/xxx/documents are both definded with the same glob files', async () => { const prj1 = await createContext({ config: './tests/test-files/graphql.config.js', project: 'prj1', diff --git a/packages/graphql-codegen-cli/tests/generate-and-save.graphql-config.spec.ts b/packages/graphql-codegen-cli/tests/generate-and-save.graphql-config.spec.ts deleted file mode 100644 index f3b694e2d65..00000000000 --- a/packages/graphql-codegen-cli/tests/generate-and-save.graphql-config.spec.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { useMonorepo } from '@graphql-codegen/testing'; -import { generate } from '../src/generate-and-save.js'; -import { createContext } from '../src/config.js'; -import * as fs from '../src/utils/file-system.js'; - -const monorepo = useMonorepo({ dirname: __dirname }); - -describe('generate-and-save - GraphQL Config', () => { - monorepo.correctCWD(); - - const originalConsole = { ...console }; - const originalNodeEnv = process.env.NODE_ENV; - - let consoleErrorMock: jest.Mock; - - beforeEach(() => { - // Mock common console functions to avoid noise in the terminal - global.console.log = jest.fn(); - global.console.warn = jest.fn(); - global.console.error = jest.fn(); - - // By default, the NODE_ENV is set to 'test', and this is used to silent console errors. - // For these tests below, we want to see what's being logged out to console errors. - process.env.NODE_ENV = 'not_test_so_error'; - - consoleErrorMock = jest.mocked(global.console.error); - }); - - afterEach(() => { - jest.resetAllMocks(); - global.console = originalConsole; - process.env.NODE_ENV = originalNodeEnv; - }); - - test('No documents found - GraphQL Config - should throw error by default', async () => { - expect.assertions(1); - try { - const config = await createContext({ - config: './tests/test-files/graphql.config.no-doc.js', - project: undefined, - errorsOnly: true, - overwrite: true, - profile: true, - require: [], - silent: false, - watch: false, - }); - - await generate(config, false); - } catch { - expect(consoleErrorMock.mock.calls[0][0]).toBeSimilarStringTo(` - [FAILED] - [FAILED] Unable to find any GraphQL type definitions for the following pointers: - [FAILED] - [FAILED] - ../test-documents/empty.graphql - `); - } - }); - - test('No documents found - GraphQL Config - should not fail if ignoreNoDocuments=true', async () => { - jest.spyOn(fs, 'writeFile').mockImplementation(); - const config = await createContext({ - config: './tests/test-files/graphql.config.no-doc-ignored.js', - project: undefined, - errorsOnly: true, - overwrite: true, - profile: true, - require: [], - silent: false, - watch: false, - }); - - await generate(config, false); - - expect(consoleErrorMock).not.toHaveBeenCalled(); - }); -}); diff --git a/packages/graphql-codegen-cli/tests/generate-and-save.spec.ts b/packages/graphql-codegen-cli/tests/generate-and-save.spec.ts index 8e4a2617a4d..549ca460eca 100644 --- a/packages/graphql-codegen-cli/tests/generate-and-save.spec.ts +++ b/packages/graphql-codegen-cli/tests/generate-and-save.spec.ts @@ -2,6 +2,7 @@ import { dirname, join } from 'path'; import { Types } from '@graphql-codegen/plugin-helpers'; import { useMonorepo } from '@graphql-codegen/testing'; import makeDir from 'make-dir'; +import { createContext } from '../src/config.js'; import { generate } from '../src/generate-and-save.js'; import * as fs from '../src/utils/file-system.js'; @@ -380,5 +381,48 @@ describe('generate-and-save', () => { ); expect(consoleErrorMock).not.toHaveBeenCalled(); }); + + test('No documents found - GraphQL Config - should throw error by default', async () => { + expect.assertions(1); + try { + const config = await createContext({ + config: './tests/test-files/graphql.config.no-doc.js', + project: undefined, + errorsOnly: true, + overwrite: true, + profile: true, + require: [], + silent: false, + watch: false, + }); + + await generate(config, false); + } catch { + expect(consoleErrorMock.mock.calls[0][0]).toBeSimilarStringTo(` + [FAILED] + [FAILED] Unable to find any GraphQL type definitions for the following pointers: + [FAILED] + [FAILED] - ../test-documents/empty.graphql + `); + } + }); + + test('No documents found - GraphQL Config - should not fail if ignoreNoDocuments=true', async () => { + jest.spyOn(fs, 'writeFile').mockImplementation(); + const config = await createContext({ + config: './tests/test-files/graphql.config.no-doc-ignored.js', + project: undefined, + errorsOnly: true, + overwrite: true, + profile: true, + require: [], + silent: false, + watch: false, + }); + + await generate(config, false); + + expect(consoleErrorMock).not.toHaveBeenCalled(); + }); }); });