-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Cache: Fix check if endpoint is /graphql
or not
#15599
Conversation
/graphql
or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR affects all POST requests. Changes in progress...
In fact this is not working as expected and will break eveything. |
Make sure you clear your own cache during testing occasionally |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also gotta make sure we don't cache if the body includes mutations
This seems to already be handled here: Edit: |
e6debfc
to
fb787ff
Compare
Description
By using
CACHE_STATUS_HEADER
we were able to check that Graphql requests always reportedMISS
which means that Graphql requests were not being cached.The source of the issue is that Express reports on
req.path
the route we defined for the controller.For example, we have a router for entire application where we define
router.post('/graphl', graphqlRouter)
.Then we define
graphqlRouter.post('/', handler)
. In this case, inside handler ourreq.path
will be/
because/graphql
was defined on parent.In order to solve the issue we take
req.originalUrl
which contains the entire path of the request.Also, it seems that System Graphql was not being cached, so I added those too, but let me know if that's intended and I can remove it.After fixing the initial issue I found that every request was responding with the Grapqhl Introspection.
This was cause by retrieving the same key every time because
req.query
for Grapqhl requests does/should not exist.So fixed the key to be based on
req.body
Type of Change
Requirements Checklist
If adding a new feature: