diff --git a/querybuilder/marshal.go b/querybuilder/marshal.go index df013e5f8..2598bb1ed 100644 --- a/querybuilder/marshal.go +++ b/querybuilder/marshal.go @@ -66,7 +66,7 @@ func marshalValue(ctx context.Context, v reflect.Value) (string, error) { var buf bytes.Buffer gqlgen.MarshalString(v.String()).MarshalGQL(&buf) return buf.String(), nil //nolint:gosimple,staticcheck - case reflect.Pointer: + case reflect.Pointer, reflect.Interface: if v.IsNil() { return "null", nil } diff --git a/querybuilder/querybuilder.go b/querybuilder/querybuilder.go index 037bd98a5..c2841e513 100644 --- a/querybuilder/querybuilder.go +++ b/querybuilder/querybuilder.go @@ -168,15 +168,16 @@ func (s *Selection) Execute(ctx context.Context, c graphql.Client) error { } type argument struct { - value any - marshalled string - once sync.Once + value any + + marshalled string + marshalledErr error + once sync.Once } func (a *argument) marshal(ctx context.Context) error { - var err error a.once.Do(func() { - a.marshalled, err = MarshalGQL(ctx, a.value) + a.marshalled, a.marshalledErr = MarshalGQL(ctx, a.value) }) - return err + return a.marshalledErr }