dotansimha / dotansimha/graphql-code-generator
Error: pluginHelpers.isDetailedError is not a function
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
### Which packages are impacted by your issue?
_No response_
### Describe the bug
Doesn't print out the proper error message.
### Your Example Website or App
none
### Steps to Reproduce the Bug or Issue
I think any error will work?
Here is the real error:
```
AggregateError: GraphQL Document Validation failed with 1 errors;
Error 0: GraphQLDocumentError: Cannot query field "xxx" on type "Mutation".
```
### Expected behavior
The error is printed out.
I added a solution below that does work.
### Screenshots or Videos
_No response_
### Platform
- OS: macos
- NodeJS: 16.19.1
- `graphql` version: ^14.1.1
- `@graphql-codegen/*` version(s): ^2.3.0
### Codegen Config File
overwrite: true
schema: 'http://localhost:4000/graphql'
extensions:
codegen:
config:
arrayInputCoercion: false
immutableTypes: true
namingConvention: keep
scalars:
DateOnly: string
DateTime: string
generates:
src/generated/graphql.ts:
plugins:
- add:
content: |
/* eslint-disable */ /* prettier-ignore */
/* * * * * * * * * * * * * * * * * * * * * * *
THIS FILE IS GENERATED, DO NOT EDIT!
(use `npm run codegen` to update)
* * * * * * * * * * * * * * * * * * * * * * */
- typescript
- typescript-operations
### Additional context
```
class Renderer {
constructor(tasks, options) {
this.updateRenderer = new UpdateRenderer(tasks, options);
}
render() {
return this.updateRenderer.render();
}
end(err) {
this.updateRenderer.end(err);
if (typeof err === 'undefined') {
logUpdate.clear();
return;
}
// persist the output
logUpdate.done();
// show errors
if (err) {
const errorCount = err.errors ? err.errors.length : 0;
if (errorCount > 0) {
const count = indentString(chalk.red.bold(`Found ${errorCount} error${errorCount > 1 ? 's' : ''}`), 1);
const details = err.errors
.map(error => {
debugLog(`[CLI] Exited with an error`, error);
return { msg: pluginHelpers.isDetailedError(error) ? error.details : null, rawError: error }; // <========= breaking
})
.map(({ msg, rawError }, i) => {
const source = err.errors[i].source;
msg = msg ? chalk.gray(indentString(commonTags.stripIndent(`${msg}`), 4)) : null;
const stack = rawError.stack ? chalk.gray(indentString(commonTags.stripIndent(rawError.stack), 4)) : null;
if (source) {
const sourceOfError = typeof source === 'string' ? source : source.name;
const title = indentString(`${logSymbols.error} ${sourceOfError}`, 2);
return [title, msg, stack, stack].filter(Boolean).join('\n');
}
return [msg, stack].filter(Boolean).join('\n');
})
.join('\n\n');
logUpdate.emit(['', count, details, ''].join('\n\n'));
}
else {
const details = err.details ? err.details : '';
logUpdate.emit(`${chalk.red.bold(`${indentString(err.message, 2)}`)}\n${details}\n${chalk.grey(err.stack)}`);
}
}
logUpdate.done();
printLogs();
}
}
```
**Solution**
```
return { msg: error?.details ? error.details : null, rawError: error };
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.