You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A DataFetcherResult inside an Optional is never unwrapped #939
A resolver method that returns a DataFetcherResult inside an Optional gives graphql-java the DataFetcherResult itself as the field value, so the data comes out wrong and its errors are lost.
with no errors. A String field gets "DataFetcherResult{data=a, errors=[], localContext=null, extensions=null}" as its value.
Two other shapes fail the build instead:
a list, e.g. Optional<DataFetcherResult<List<Payload>>> for [Payload]
Java class is not a List or generic type information was lost: graphql.execution.DataFetcherResult<java.util.List>
any other field that returns Payload some other way, e.g. a plain Payload or a DataFetcherResult<Optional<Payload>>
Two different classes used for type Payload
Steps to reproduce the bug
Return Optional<DataFetcherResult<T>> from a resolver method.
Query the field.
Cause
TypeClassMatcher.PotentialMatch.unwrap checks for a DataFetcherResult before an Optional but never after one. So for Optional<DataFetcherResult<Payload>> the build binds Payload to the DataFetcherResult class. At runtime graphql-java unboxes the Optional but doesn't look for a DataFetcherResult inside it, so the field resolves data on the DataFetcherResult object.
Activity