Skip to content

Commit 1c7a8c0

Browse files
authored
fix(ci): regression on error output (#8198)
1 parent 44db543 commit 1c7a8c0

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

.changeset/rotten-lemons-wash.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@graphql-codegen/cli": patch
3+
---
4+
5+
fix(ci): regression on error output

packages/graphql-codegen-cli/src/codegen.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,11 @@ export async function executeCodegen(input: CodegenContext | Types.Config): Prom
404404
// Running tasks doesn't throw anything
405405
const executedContext = await tasks.run();
406406

407+
if (config.debug) {
408+
// if we have debug logs, make sure to print them before throwing the errors
409+
printLogs();
410+
}
411+
407412
if (executedContext.errors.length > 0) {
408413
const errors = executedContext.errors.map(subErr =>
409414
isDetailedError(subErr)
@@ -416,9 +421,5 @@ export async function executeCodegen(input: CodegenContext | Types.Config): Prom
416421
throw newErr;
417422
}
418423

419-
if (config.debug) {
420-
printLogs();
421-
}
422-
423424
return result;
424425
}

packages/graphql-codegen-cli/src/load.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
loadDocuments as loadDocumentsToolkit,
44
UnnormalizedTypeDefPointer,
55
} from '@graphql-tools/load';
6-
import { DetailedError, Types } from '@graphql-codegen/plugin-helpers';
6+
import { Types } from '@graphql-codegen/plugin-helpers';
77
import { GraphQLSchema } from 'graphql';
88
import { CodeFileLoader } from '@graphql-tools/code-file-loader';
99
import { GitLoader } from '@graphql-tools/git-loader';
@@ -51,8 +51,7 @@ export async function loadSchema(
5151
});
5252
return schema;
5353
} catch (e) {
54-
throw new DetailedError(
55-
'Failed to load schema',
54+
throw new Error(
5655
`
5756
Failed to load schema from ${Object.keys(schemaPointers).join(',')}:
5857

packages/graphql-codegen-cli/tests/codegen.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ describe('Codegen Executor', () => {
10651065
},
10661066
});
10671067
} catch (error) {
1068-
expect(error.message).toContain('Failed to load schema for "out1.graphql"');
1068+
expect(error.message).toContain('Failed to load schema from');
10691069
}
10701070
});
10711071

0 commit comments

Comments
 (0)