Skip to content

Commit

Permalink
fix(server): multiple default value bug (#1229)
Browse files Browse the repository at this point in the history
* fix: multiple default value bug
  • Loading branch information
nourbalaha authored Sep 13, 2024
1 parent b60c873 commit b799d8c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion server/internal/adapter/gql/gqlmodel/convert_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gqlmodel

import (
"reflect"
"strings"

"github.com/reearth/reearth-cms/server/pkg/id"
"github.com/reearth/reearth-cms/server/pkg/schema"
Expand Down Expand Up @@ -636,9 +637,17 @@ func unpackArray(s any) []any {
return nil
}
v := reflect.ValueOf(s)
if v.Kind() != reflect.Slice {
return nil
}
r := make([]any, v.Len())
for i := 0; i < v.Len(); i++ {
r[i] = v.Index(i).Interface()
elem := v.Index(i).Interface()
if str, ok := elem.(string); ok && strings.TrimSpace(str) == "" {
r[i] = nil
} else {
r[i] = elem
}
}
return r
}

0 comments on commit b799d8c

Please sign in to comment.