Skip to content

Commit

Permalink
fix(value-resolver): check if values have been pushed already
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <[email protected]>
  • Loading branch information
paralin committed Jan 3, 2023
1 parent e1b9d6d commit d9e7978
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions directive/value-resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ func NewValueResolver[T any](vals []T) *ValueResolver[T] {

// Resolve resolves the values, emitting them to the handler.
func (r *ValueResolver[T]) Resolve(ctx context.Context, handler ResolverHandler) error {
existingVals := handler.CountValues(false)
if existingVals == len(r.vals) {
return nil
}
if existingVals != 0 {
handler.ClearValues()
}
for _, value := range r.vals {
_, _ = handler.AddValue(value)
}
Expand Down

0 comments on commit d9e7978

Please sign in to comment.