11import {
2- DetailedError ,
32 Types ,
43 CodegenPlugin ,
54 normalizeOutputParam ,
65 normalizeInstanceOrArray ,
76 normalizeConfig ,
87 getCachedDocumentNodeFromSchema ,
9- isDetailedError ,
108} from '@graphql-codegen/plugin-helpers' ;
119import { codegen } from '@graphql-codegen/core' ;
1210
@@ -51,7 +49,7 @@ const makeDefaultLoader = (from: string) => {
5149 } ;
5250} ;
5351
54- type Ctx = { errors : DetailedError [ ] | Error [ ] } ;
52+ type Ctx = { errors : Error [ ] } ;
5553
5654function createCache ( ) : < T > ( namespace : string , key : string , factory : ( ) => Promise < T > ) => Promise < T > {
5755 const cache = new Map < string , Promise < unknown > > ( ) ;
@@ -123,9 +121,8 @@ export async function executeCodegen(input: CodegenContext | Types.Config): Prom
123121 const generateKeys = Object . keys ( config . generates || { } ) ;
124122
125123 if ( generateKeys . length === 0 ) {
126- throw new DetailedError (
127- 'Invalid Codegen Configuration!' ,
128- `
124+ throw new Error (
125+ `Invalid Codegen Configuration! \n
129126 Please make sure that your codegen config file contains the "generates" field, with a specification for the plugins you need.
130127
131128 It should looks like that:
@@ -136,18 +133,16 @@ export async function executeCodegen(input: CodegenContext | Types.Config): Prom
136133 my-file.ts:
137134 - plugin1
138135 - plugin2
139- - plugin3
140- `
136+ - plugin3`
141137 ) ;
142138 }
143139
144140 for ( const filename of generateKeys ) {
145141 const output = ( generates [ filename ] = normalizeOutputParam ( config . generates [ filename ] ) ) ;
146142
147143 if ( ! output . preset && ( ! output . plugins || output . plugins . length === 0 ) ) {
148- throw new DetailedError (
149- 'Invalid Codegen Configuration!' ,
150- `
144+ throw new Error (
145+ `Invalid Codegen Configuration! \n
151146 Please make sure that your codegen config file has defined plugins list for output "${ filename } ".
152147
153148 It should looks like that:
@@ -173,9 +168,8 @@ export async function executeCodegen(input: CodegenContext | Types.Config): Prom
173168 ( generates [ filename ] . schema as unknown as any [ ] ) . length === 0 )
174169 )
175170 ) {
176- throw new DetailedError (
177- 'Invalid Codegen Configuration!' ,
178- `
171+ throw new Error (
172+ `Invalid Codegen Configuration! \n
179173 Please make sure that your codegen config file contains either the "schema" field
180174 or every generated file has its own "schema" field.
181175
@@ -419,11 +413,7 @@ export async function executeCodegen(input: CodegenContext | Types.Config): Prom
419413 }
420414
421415 if ( executedContext . errors . length > 0 ) {
422- const errors = executedContext . errors . map ( subErr =>
423- isDetailedError ( subErr )
424- ? `${ subErr . message } for "${ subErr . source } "${ subErr . details } `
425- : subErr . message || subErr . toString ( )
426- ) ;
416+ const errors = executedContext . errors . map ( subErr => subErr . message || subErr . toString ( ) ) ;
427417 const newErr = new AggregateError ( executedContext . errors , `${ errors . join ( '\n\n' ) } ` ) ;
428418 // Best-effort to all stack traces for debugging
429419 newErr . stack = `${ newErr . stack } \n\n${ executedContext . errors . map ( subErr => subErr . stack ) . join ( '\n\n' ) } ` ;
0 commit comments