github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/pkg/graphql/labels.go (about) 1 package graphql 2 3 import ( 4 "io" 5 6 "github.com/kyma-incubator/compass/components/director/pkg/apperrors" 7 8 "github.com/kyma-incubator/compass/components/director/pkg/log" 9 10 "github.com/kyma-incubator/compass/components/director/pkg/scalar" 11 12 "github.com/pkg/errors" 13 ) 14 15 // Labels missing godoc 16 type Labels map[string]interface{} 17 18 // UnmarshalGQL missing godoc 19 func (y *Labels) UnmarshalGQL(v interface{}) error { 20 if v == nil { 21 return apperrors.NewInternalError("input should not be nil") 22 } 23 24 value, ok := v.(map[string]interface{}) 25 if !ok { 26 return errors.Errorf("unexpected Labels type: %T, should be map[string]interface{}", v) 27 } 28 29 *y = value 30 31 return nil 32 } 33 34 // MarshalGQL missing godoc 35 func (y Labels) MarshalGQL(w io.Writer) { 36 err := scalar.WriteMarshalled(y, w) 37 if err != nil { 38 log.D().Errorf("while writing %T: %s", y, err) 39 return 40 } 41 }