@@ -202,7 +202,15 @@ export class GolangGenerator {
202202 const goType : string = this . types [ node . name . value ] as string
203203 l . push ( '' , `type ${ goType } struct {` )
204204 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+ }
206214 } )
207215 l . push ( '}' )
208216 } )
@@ -215,7 +223,15 @@ export class GolangGenerator {
215223 const goType : string = this . types [ node . name . value ] as string
216224 l . push ( '' , `type ${ goType } struct {` )
217225 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+ }
219235 } )
220236 l . push ( '}' )
221237 } )
@@ -267,8 +283,9 @@ export class GolangGenerator {
267283 nonNull
268284 )
269285 }
270- console . debug ( `Skipped unsupported field type "${ type . name . value } "` )
271- return ''
286+ throw new UnsupportedTypeError (
287+ `unsupported field type "${ type . name . value } "`
288+ )
272289 }
273290
274291 /**
@@ -370,7 +387,15 @@ export class GolangGenerator {
370387 }
371388 const l : string [ ] = [ `type ${ name } Variables struct {` ]
372389 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+ }
374399 } )
375400 l . push ( '}' , '' )
376401 return l
@@ -399,3 +424,10 @@ export class GolangGenerator {
399424 return l
400425 }
401426}
427+
428+ class UnsupportedTypeError extends Error {
429+ constructor ( msg : string ) {
430+ super ( msg )
431+ Object . setPrototypeOf ( this , UnsupportedTypeError . prototype )
432+ }
433+ }
0 commit comments