Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
We've created a yoga (gql server) hook that catches requests and cache them when needed. In practice we use it on the "objects" query because this is often queried on the FE and it should never return something different unless the schema has been intentionally changed by the user when editing their data model (updating objects, fields, etc).
The issue here is we always cache the response regardless of its result, even when it fails. This PR fixes that behaviour by only caching the query response if it is successful.
I'm also fixing the cache key because the signature let users put multiple operations and the cache key was not taking this into account (we always use it on only one operation but we might have issues in the future because another operation response could have erased the cached response of another). Now the cache key contains the name of the operation as well.
Test
tested locally by manually throwing an error in the JWT auth guard