Skip to content

Fix isGraphQLQuery check in response-cache plugin#2792

Merged
abernix merged 3 commits intoapollographql:masterfrom
fabsrc:fix/graphql-query-check
Jun 25, 2019
Merged

Fix isGraphQLQuery check in response-cache plugin#2792
abernix merged 3 commits intoapollographql:masterfrom
fabsrc:fix/graphql-query-check

Conversation

@fabsrc
Copy link
Copy Markdown
Contributor

@fabsrc fabsrc commented Jun 7, 2019

Fixes #2745

@intellix
Copy link
Copy Markdown

For the impatient using https://github.com/ds300/patch-package:

diff --git a/node_modules/apollo-server-plugin-response-cache/dist/ApolloServerPluginResponseCache.js b/node_modules/apollo-server-plugin-response-cache/dist/ApolloServerPluginResponseCache.js
index 67a298a..7130a03 100644
--- a/node_modules/apollo-server-plugin-response-cache/dist/ApolloServerPluginResponseCache.js
+++ b/node_modules/apollo-server-plugin-response-cache/dist/ApolloServerPluginResponseCache.js
@@ -26,7 +26,9 @@ function cacheKeyString(key) {
     return sha(JSON.stringify(key));
 }
 function isGraphQLQuery(requestContext) {
-    return requestContext.operation.operation === 'query';
+  return (
+    requestContext.operation && requestContext.operation.operation === 'query'
+  );
 }
 function plugin(options = Object.create(null)) {
     return {

@fabsrc
Copy link
Copy Markdown
Contributor Author

fabsrc commented Jun 25, 2019

@abernix or @glasser: could you please have a look at this? 🙂

Copy link
Copy Markdown
Member

@abernix abernix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much!

(And, if I'm not mistaken, pleasure to run into you on the streets of Berlin and discuss this PR! 😺)

@abernix abernix merged commit 0ae49d3 into apollographql:master Jun 25, 2019
@abernix abernix added this to the Release 2.6.6 milestone Jun 25, 2019
@fabsrc fabsrc deleted the fix/graphql-query-check branch June 25, 2019 18:27
@glasser
Copy link
Copy Markdown
Member

glasser commented Jun 25, 2019

Good catch, thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorect behavior of plugin apollo-server-plugin-response-cache in case of validation error on client request

4 participants