I have defined Subgraphs to fetch data from multiple sources
type MyResult{
id: ID
innerResults: [InnerResult] @external
otherResults: [OtherResult] @requires(fields: "innerResults")
}
DgsEntityFetcher looks like below
@DgsEntityFetcher(name = DgsConstants.MYRESULT.TYPE_NAME)
public DataFetcherResult<MyResult> getResults(Map<String, Object> values) {
values.forEach((k,val) -> log.warn("key {} value{}",k,val));
return DataFetcherResult.<MyResult>newResult()
.data(PlacedDeviceResult.newBuilder().Id((String)values.get("id")).innerResults((List<InnerResult>) values.get("innerResults")).build())
.build();
}
But this is not working giving exception
java.util.LinkedHashMap cannot be cast to class com.company.InnerResult (java.util.LinkedHashMap is in module java.base of loader 'bootstrap'; com.company.InnerResult is in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @40a72ecd)
java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class com.company.InnerResult (java.util.LinkedHashMap is in module java.base of loader 'bootstrap'; com.company.InnerResult is in unnamed module of loader org.springframework.boot.loader.LaunchedURLClassLoader @40a72ecd)