graphql-java-kickstart/graphql-java-tools

Is it possible to return a ResponseEntity<T> from a resolver

naveen4801 opened this issue · 0 comments

I'm using graphql-java with spring boot.
My schema looks like this.
type Query{
userById(id: String): User
}
type User {
id: String
name: String
email: String
}
I have a QueryResolver class that implements GraphQLQueryResolver. My get method inside this class looks like this.
public User getUserById(String id) {
return someClient.getUserById(id).getBody(); //getUserById inside someClient returns a ResponseEntity
}
What I need inside my QueryResolver is to return a ResponseEntity instead of a User. So it'll look like the code below
public ResponseEntity getUserById(String id) {
return someClient.getUserById(id);
}
The above code returns a schema error saying org.springframework.http.ResponseEntity cannot be mapped to a GraphQL type! Since GraphQL-Java deals with erased types at runtime, only non-parameterized classes can represent a GraphQL type. What does this mean? Is it possible to return a ResponseEntity<> from a resolver?