Skip to content

Commit 1e00697

Browse files
committed
fix: incorrect scalars in operations
1 parent bf0ad87 commit 1e00697

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

cmd/recodegen/recodegen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"runtime"
1414
)
1515

16-
const VERSION = "v0.4.0"
16+
const VERSION = "v0.4.1"
1717

1818
func main() {
1919
configFileName := flag.String("config", "recodegen.json", "Configuration file name")

npm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@graphql-recodegen/cli",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"description": "Faster GraphQL codegen for TypeScript projects",
55
"main": "index.js",
66
"type": "module",

typescript/operation.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ type Operations struct {
2222

2323
func (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

363373
func 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

Comments
 (0)