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 Metadata GQL server hook #6323

Merged
merged 1 commit into from
Jul 18, 2024
Merged

Conversation

Weiko
Copy link
Member

@Weiko Weiko commented Jul 18, 2024

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

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

  • Fixed caching of GraphQL server hook for "objects" query
  • Updated cache key to include operation name
  • Prevented caching of failed query responses
  • Improved error handling in JWT auth guard
  • Enhanced query caching efficiency for data model changes

No file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

@Weiko Weiko merged commit 65e8503 into main Jul 18, 2024
6 checks passed
@Weiko Weiko deleted the c--fix-cached-metadata-gql-server-hook branch July 18, 2024 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants