Skip to content

Commit

Permalink
feat: support passing core type arrays to dagger call (#6030)
Browse files Browse the repository at this point in the history
* fix: always propagate error from marshalling

Failing to marshal an argument should be preserved - if the caller
discards the error, expecting it to fail later, the behaviour is very
strange, and we get an empty string.

Signed-off-by: Justin Chadwell <[email protected]>

* fix: marshal interface types as their element

Signed-off-by: Justin Chadwell <[email protected]>

* feat: support passing core type arrays to dagger call

Signed-off-by: Justin Chadwell <[email protected]>

---------

Signed-off-by: Justin Chadwell <[email protected]>
  • Loading branch information
jedevc authored Oct 31, 2023
1 parent 351d54f commit dbf26a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion querybuilder/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
13 changes: 7 additions & 6 deletions querybuilder/querybuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit dbf26a1

Please sign in to comment.