Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci): regression on error output #8198

Merged
merged 5 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rotten-lemons-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphql-codegen/cli": patch
---

fix(ci): regression on error output
9 changes: 5 additions & 4 deletions packages/graphql-codegen-cli/src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -416,9 +421,5 @@ export async function executeCodegen(input: CodegenContext | Types.Config): Prom
throw newErr;
}

if (config.debug) {
printLogs();
}

return result;
}
5 changes: 2 additions & 3 deletions packages/graphql-codegen-cli/src/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(',')}:

Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-codegen-cli/tests/codegen.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
});

Expand Down