dapr / dapr/java-sdk

Add support for invokeBindings that return a list of typed objects

Open
#1,067 0 comments 0 reactions 0 assignees View on GitHub
kind/bug
Dominant language
Java
Stars
300
Forks
230
Avg merge
1d 20h
Merged PRs (30d)
4

Description

## Expected Behavior

I want to invoke a binding that returns a collection of items of a given type using Java Generic parameters.
Currently the invoke binding supports specifying a TypeRef to automatically deserialize the binding invocation result:

```
String result = client.invokeBinding("BindingName", "MyOperation", event, TypeRef.get(String.class)).block();
```

The output of the binding in this case will be casted to a String. If you are executing a query binding, for example using the `binding.postgresql` query operation, the result will be a collection of objects returned by the query. For such situations, the TypeRef specified should be the type that will be used to deserialize each item on the collection. If a List is specified as the return type, the deserialization code doesn't know which type each item of the collection it is.

List result = client.invokeBinding("BindingName", "MyOperation", event, TypeRef.get(List.class)).block();

## Actual Behavior

It is impossible to deserialize a list of items of a given type when invoking a binding.

## Steps to Reproduce the Problem

PR showing a test -> https://github.com/dapr/java-sdk/pull/1068

## Release Note

RELEASE NOTE:

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.