diff --git a/.changeset/rotten-lemons-wash.md b/.changeset/rotten-lemons-wash.md new file mode 100644 index 00000000000..3307fbfa1e3 --- /dev/null +++ b/.changeset/rotten-lemons-wash.md @@ -0,0 +1,5 @@ +--- +"@graphql-codegen/cli": patch +--- + +fix(ci): regression on error output diff --git a/packages/graphql-codegen-cli/src/codegen.ts b/packages/graphql-codegen-cli/src/codegen.ts index 5bf73432b6f..f04deb01c0c 100644 --- a/packages/graphql-codegen-cli/src/codegen.ts +++ b/packages/graphql-codegen-cli/src/codegen.ts @@ -404,6 +404,11 @@ export async function executeCodegen(input: CodegenContext | Types.Config): Prom // Running tasks doesn't throw anything const executedContext = await tasks.run(); + if (config.debug) { + // if we have debug logs, make sure to print them before throwing the errors + printLogs(); + } + if (executedContext.errors.length > 0) { const errors = executedContext.errors.map(subErr => isDetailedError(subErr) @@ -416,9 +421,5 @@ export async function executeCodegen(input: CodegenContext | Types.Config): Prom throw newErr; } - if (config.debug) { - printLogs(); - } - return result; } diff --git a/packages/graphql-codegen-cli/src/load.ts b/packages/graphql-codegen-cli/src/load.ts index ddc166bd5b2..f0e56edd1c1 100644 --- a/packages/graphql-codegen-cli/src/load.ts +++ b/packages/graphql-codegen-cli/src/load.ts @@ -3,7 +3,7 @@ import { loadDocuments as loadDocumentsToolkit, UnnormalizedTypeDefPointer, } from '@graphql-tools/load'; -import { DetailedError, Types } from '@graphql-codegen/plugin-helpers'; +import { Types } from '@graphql-codegen/plugin-helpers'; import { GraphQLSchema } from 'graphql'; import { CodeFileLoader } from '@graphql-tools/code-file-loader'; import { GitLoader } from '@graphql-tools/git-loader'; @@ -51,8 +51,7 @@ export async function loadSchema( }); return schema; } catch (e) { - throw new DetailedError( - 'Failed to load schema', + throw new Error( ` Failed to load schema from ${Object.keys(schemaPointers).join(',')}: diff --git a/packages/graphql-codegen-cli/tests/codegen.spec.ts b/packages/graphql-codegen-cli/tests/codegen.spec.ts index 127a24d9688..24ced0dd6c3 100644 --- a/packages/graphql-codegen-cli/tests/codegen.spec.ts +++ b/packages/graphql-codegen-cli/tests/codegen.spec.ts @@ -1065,7 +1065,7 @@ describe('Codegen Executor', () => { }, }); } catch (error) { - expect(error.message).toContain('Failed to load schema for "out1.graphql"'); + expect(error.message).toContain('Failed to load schema from'); } });