Skip to content

Commit

Permalink
fix(ci): regression on error output (#8198)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlypoly committed Aug 8, 2022
1 parent 44db543 commit 1c7a8c0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/rotten-lemons-wash.md
@@ -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
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
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
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

1 comment on commit 1c7a8c0

@vercel
Copy link

@vercel vercel bot commented on 1c7a8c0 Aug 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.