-
Couldn't load subscription status.
- Fork 112
Description
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
GraphQLConfigurationwith aGraphQLResponseCacheManageras 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.
Lines 30 to 35 in 36ae1d1
| boolean returnedFromCache; | |
| try { | |
| returnedFromCache = !CacheReader.responseFromCache( | |
| invocationInput, request, response, configuration.getResponseCacheManager() | |
| ); |
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.
Lines 42 to 44 in 36ae1d1
| if (!returnedFromCache) { | |
| requestInvoker.execute(invocationInput, request, response); | |
| } |
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.
Line 33 in 36ae1d1
| returnedFromCache = !CacheReader.responseFromCache( |
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!