Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix isGraphQLQuery check in response-cache plugin #2792

Merged
merged 3 commits into from
Jun 25, 2019
Merged

Fix isGraphQLQuery check in response-cache plugin #2792

merged 3 commits into from
Jun 25, 2019

Conversation

fabsrc
Copy link
Contributor

@fabsrc fabsrc commented Jun 7, 2019

Fixes #2745

@intellix
Copy link

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
Contributor Author

fabsrc commented Jun 25, 2019

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

Copy link
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
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