Response body empty when response caching configured
venushka opened this issue · 1 comments
When GraphQLConfiguration
is built with a GraphQLResponseCacheManager
instance, the HTTP response body is empty. The servlet is created as follows,
public class GraphQLServlet extends GraphQLHttpServlet {
...
@Override
protected GraphQLConfiguration getConfiguration() {
return GraphQLConfiguration
.with(graphQLSchemaService)
.with(graphQLResponseCacheManager)
.build();
}
}
To Reproduce
Steps to reproduce the behavior:
- Build the
GraphQLConfiguration
with aGraphQLResponseCacheManager
as shown above. - Make a GraphQL request to the servlet
- Response body is empty with a 200 OK response code.
Expected behavior
Result of the GraphQL query execution
Additional context
Looking through the code, it seems like the issue is in the following bit of code.
The CacheReader
returns false
if the content is not served from cache, and here the returnedFromCache
is set to the negate of the return value making it true
.
This means the following condition is not met, so the query is not processed by the HttpRequestInvoker
, resulting in no response in being sent to the client.
I think the fix is to just remove the !
in the following line, which seems to align with the naming of the variable and the associated comment.
With this change, it works as expected locally. Would be great to get this fixed and released.
p.s. Its great to have response caching supported, many thanks!
Thanks for getting this fixed so quickly! @oliemansm