@@ -202,7 +202,15 @@ export class GolangGenerator {
202
202
const goType : string = this . types [ node . name . value ] as string
203
203
l . push ( '' , `type ${ goType } struct {` )
204
204
node . fields ?. forEach ( field => {
205
- l . push ( this . _generateField ( field . name . value , field . type ) )
205
+ try {
206
+ l . push ( this . _generateField ( field . name . value , field . type ) )
207
+ } catch ( e ) {
208
+ if ( e instanceof UnsupportedTypeError ) {
209
+ console . debug ( `Skipping ${ e . message } ` )
210
+ } else {
211
+ throw e
212
+ }
213
+ }
206
214
} )
207
215
l . push ( '}' )
208
216
} )
@@ -215,7 +223,15 @@ export class GolangGenerator {
215
223
const goType : string = this . types [ node . name . value ] as string
216
224
l . push ( '' , `type ${ goType } struct {` )
217
225
node . fields ?. forEach ( field => {
218
- l . push ( this . _generateField ( field . name . value , field . type ) )
226
+ try {
227
+ l . push ( this . _generateField ( field . name . value , field . type ) )
228
+ } catch ( e ) {
229
+ if ( e instanceof UnsupportedTypeError ) {
230
+ console . debug ( `Skipping ${ e . message } ` )
231
+ } else {
232
+ throw e
233
+ }
234
+ }
219
235
} )
220
236
l . push ( '}' )
221
237
} )
@@ -267,8 +283,9 @@ export class GolangGenerator {
267
283
nonNull
268
284
)
269
285
}
270
- console . debug ( `Skipped unsupported field type "${ type . name . value } "` )
271
- return ''
286
+ throw new UnsupportedTypeError (
287
+ `unsupported field type "${ type . name . value } "`
288
+ )
272
289
}
273
290
274
291
/**
@@ -370,7 +387,15 @@ export class GolangGenerator {
370
387
}
371
388
const l : string [ ] = [ `type ${ name } Variables struct {` ]
372
389
variableDefinitions . forEach ( variable => {
373
- l . push ( this . _generateField ( variable . variable . name . value , variable . type ) )
390
+ try {
391
+ l . push ( this . _generateField ( variable . variable . name . value , variable . type ) )
392
+ } catch ( e ) {
393
+ if ( e instanceof UnsupportedTypeError ) {
394
+ console . debug ( `Skipping ${ e . message } ` )
395
+ } else {
396
+ throw e
397
+ }
398
+ }
374
399
} )
375
400
l . push ( '}' , '' )
376
401
return l
@@ -399,3 +424,10 @@ export class GolangGenerator {
399
424
return l
400
425
}
401
426
}
427
+
428
+ class UnsupportedTypeError extends Error {
429
+ constructor ( msg : string ) {
430
+ super ( msg )
431
+ Object . setPrototypeOf ( this , UnsupportedTypeError . prototype )
432
+ }
433
+ }
0 commit comments