Skip to content

Commit 8836fab

Browse files
committed
Pass HttpServletRequest to GraphQLResponseCache methods.
1 parent b66190e commit 8836fab

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

graphql-java-servlet/src/main/java/graphql/kickstart/servlet/BatchedQueryResponseWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void write(HttpServletRequest request, HttpServletResponse response, Grap
4444

4545
if (responseCache != null) {
4646
try {
47-
responseCache.cacheResponse(invocationInput, CachedResponse.ofContent(contentBytes));
47+
responseCache.cacheResponse(request, invocationInput, CachedResponse.ofContent(contentBytes));
4848
} catch (Throwable t) {
4949
log.warn(t.getMessage(), t);
5050
log.warn("Ignore read from cache, unexpected error happened");

graphql-java-servlet/src/main/java/graphql/kickstart/servlet/HttpRequestHandlerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private void execute(GraphQLInvocationInput invocationInput, HttpServletRequest
5555
if (configuration.getResponseCache() != null) {
5656
CachedResponse cachedResponse = null;
5757
try {
58-
cachedResponse = configuration.getResponseCache().getCachedResponse(invocationInput);
58+
cachedResponse = configuration.getResponseCache().getCachedResponse(request, invocationInput);
5959
} catch (Throwable t) {
6060
log.warn(t.getMessage(), t);
6161
log.warn("Ignore read from cache, unexpected error happened");

graphql-java-servlet/src/main/java/graphql/kickstart/servlet/cache/GraphQLResponseCache.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import graphql.kickstart.execution.input.GraphQLInvocationInput;
44

5+
import javax.servlet.http.HttpServletRequest;
56
import java.util.Optional;
67

78
public interface GraphQLResponseCache {
@@ -12,14 +13,14 @@ public interface GraphQLResponseCache {
1213
* @param invocationInput input data
1314
* @return cached response if something available in cache or {@literal null} if nothing cached
1415
*/
15-
CachedResponse getCachedResponse(GraphQLInvocationInput invocationInput);
16+
CachedResponse getCachedResponse(HttpServletRequest request, GraphQLInvocationInput invocationInput);
1617

1718
/**
1819
* Decide to cache or not this response. It depends on the implementation.
1920
*
2021
* @param invocationInput input data
2122
* @param cachedResponse response to cache
2223
*/
23-
void cacheResponse(GraphQLInvocationInput invocationInput, CachedResponse cachedResponse);
24+
void cacheResponse(HttpServletRequest request, GraphQLInvocationInput invocationInput, CachedResponse cachedResponse);
2425

2526
}

0 commit comments

Comments
 (0)