diff --git a/pkg/graph/resolvers/model_plan.go b/pkg/graph/resolvers/model_plan.go index accc687fce..2e56e4b7af 100644 --- a/pkg/graph/resolvers/model_plan.go +++ b/pkg/graph/resolvers/model_plan.go @@ -486,7 +486,7 @@ func ModelPlanShare( modelPlanCategoriesHumainzed = append(modelPlanCategoriesHumainzed, models.ModelCategoryHumanized[*planBasics.ModelCategory]) } - for _, category := range planBasics.AdditionalModelCategories.Values { + for _, category := range planBasics.AdditionalModelCategories { // Have to cast the additional category as a models.ModelCategory so we can fetch it from the models.ModelCategoryHumanized map modelPlanCategoriesHumainzed = append(modelPlanCategoriesHumainzed, models.ModelCategoryHumanized[models.ModelCategory(category)]) } diff --git a/pkg/graph/resolvers/plan_basics.resolvers.go b/pkg/graph/resolvers/plan_basics.resolvers.go index b2a69978b6..c4f283ffd7 100644 --- a/pkg/graph/resolvers/plan_basics.resolvers.go +++ b/pkg/graph/resolvers/plan_basics.resolvers.go @@ -35,7 +35,7 @@ func (r *mutationResolver) UpdatePlanBasics(ctx context.Context, id uuid.UUID, c // AdditionalModelCategories is the resolver for the additionalModelCategories field. func (r *planBasicsResolver) AdditionalModelCategories(ctx context.Context, obj *models.PlanBasics) ([]models.ModelCategory, error) { - return obj.AdditionalModelCategories.Values, nil + return obj.AdditionalModelCategories, nil // modelCategories := models.ConvertEnums[models.ModelCategory](obj.AdditionalModelCategories.StringArray) // return modelCategories, nil } diff --git a/pkg/models/enum_array.go b/pkg/models/enum_array.go index 73554db9b3..39a51bb79d 100644 --- a/pkg/models/enum_array.go +++ b/pkg/models/enum_array.go @@ -7,30 +7,30 @@ import ( "github.com/lib/pq" ) -type EnumArray[enumType ~string] struct { - Values []enumType -} +// type EnumArray[enumType ~string] struct { +// Values []enumType +// } -// type EnumArray[enumType ~string] []enumType +type EnumArray[enumType ~string] []enumType -// Scan Implements the Scanner interface to decode data from the database +// Scan implements the Scanner interface to decode data from the database func (e *EnumArray[EnumType]) Scan(value interface{}) error { var stringArray pq.StringArray if err := stringArray.Scan(value); err != nil { return err } - e.Values = make([]EnumType, len(stringArray)) + *e = make(EnumArray[EnumType], len(stringArray)) for i, v := range stringArray { - e.Values[i] = EnumType(v) + (*e)[i] = EnumType(v) } return nil } -// Value Implements the Valuer interface to encode data into the database +// Value implements the Valuer interface to encode data into the database func (e EnumArray[EnumType]) Value() (driver.Value, error) { - stringArray := make([]string, len(e.Values)) - for i, v := range e.Values { + stringArray := make([]string, len(e)) + for i, v := range e { stringArray[i] = string(v) } return pq.StringArray(stringArray).Value() @@ -38,7 +38,7 @@ func (e EnumArray[EnumType]) Value() (driver.Value, error) { // MarshalJSON marshals the EnumArray into JSON for GraphQL func (e EnumArray[EnumType]) MarshalJSON() ([]byte, error) { - return json.Marshal(e.Values) + return json.Marshal([]EnumType(e)) } // UnmarshalJSON unmarshals the EnumArray from JSON for GraphQL @@ -48,9 +48,9 @@ func (e *EnumArray[EnumType]) UnmarshalJSON(data []byte) error { return err } - e.Values = make([]EnumType, len(stringArray)) + *e = make(EnumArray[EnumType], len(stringArray)) for i, v := range stringArray { - e.Values[i] = EnumType(v) + (*e)[i] = EnumType(v) } return nil }