add function to apply mutations over grpc
This commit is contained in:
@@ -212,9 +212,9 @@ func (r *ProtoMutationRegistry) Apply(ctx context.Context, grain any, msg ...pro
|
||||
}
|
||||
|
||||
for _, m := range msg {
|
||||
// Ignore nil mutation elements (untyped or typed nil pointers) silently; they carry no data.
|
||||
// Error if any mutation element is nil.
|
||||
if m == nil {
|
||||
continue
|
||||
return results, fmt.Errorf("nil mutation message")
|
||||
}
|
||||
// Typed nil: interface holds concrete proto message type whose pointer value is nil.
|
||||
rv := reflect.ValueOf(m)
|
||||
@@ -251,6 +251,12 @@ func (r *ProtoMutationRegistry) Apply(ctx context.Context, grain any, msg ...pro
|
||||
}
|
||||
}
|
||||
}
|
||||
// Return error for unregistered mutations
|
||||
for _, res := range results {
|
||||
if res.Error == ErrMutationNotRegistered {
|
||||
return results, res.Error
|
||||
}
|
||||
}
|
||||
return results, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user