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
Is it possible to return a ResponseEntity<T> from a resolver #588
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?
Activity