@@ -22,6 +22,16 @@ type Operations struct {
2222
2323func (operations * Operations ) String () string {
2424 typesPath := ""
25+
26+ // Load scalars if not loaded yet
27+ if len (scalarNames ) == 0 {
28+ for _ , def := range operations .Ast .Types {
29+ if def .Kind == ast .Scalar {
30+ scalarNames = append (scalarNames , def .Name )
31+ }
32+ }
33+ }
34+
2535 if operations .Config .Preset == "import-types" {
2636 typesPath = operations .Config .PresetConfig ["typesPath" ]
2737 }
@@ -361,12 +371,7 @@ func generateOpFieldType(astType *ast.Type, isImportTypes bool) string {
361371}
362372
363373func wrapOpScalar (typeName string , isImportTypes bool ) string {
364- typeName = normalizedName (typeName )
365- scalars := []string {
366- "Boolean" , "String" , "Int" , "Float8" , "Float" , "Bigint" , "Timestamp" , "Timestamptz" ,
367- "Numeric" , "Uuid" , "Json" , "Jsonb" , "Polygon" , "Point" , "Date" , "date" ,
368- }
369- for _ , scalar := range scalars {
374+ for _ , scalar := range scalarNames {
370375 if typeName == scalar {
371376 switch scalar {
372377 case "Boolean" :
@@ -375,20 +380,15 @@ func wrapOpScalar(typeName string, isImportTypes bool) string {
375380 return "string"
376381 case "Int" :
377382 return "number"
378- case "Float8" :
379- return "number"
380383 case "Float" :
381384 return "number"
382- case "Bigint" :
383- return "number"
384- case "Timestamp" :
385- return "string"
386- case "Timestamptz" :
385+ case "ID" :
387386 return "string"
388387 }
389388 return "any"
390389 }
391390 }
391+ typeName = normalizedName (typeName )
392392 if isImportTypes {
393393 typeName = "Types." + typeName
394394 }
0 commit comments