Skip to content

fix: ensure unique GraphQL schema caching per API key#16411

Merged
charlesBochet merged 5 commits intomainfrom
fix/graphql-schema-caching-api-keys
Dec 15, 2025
Merged

fix: ensure unique GraphQL schema caching per API key#16411
charlesBochet merged 5 commits intomainfrom
fix/graphql-schema-caching-api-keys

Conversation

@abdulrahmancodes
Copy link
Copy Markdown
Contributor

@abdulrahmancodes abdulrahmancodes commented Dec 9, 2025

Description

This PR fixes an issue where the GraphQL schema was being incorrectly cached and shared across different API keys within the same workspace. This resulted in the createdBy field (Actor) from the first API key's request being erroneously attributed to subsequent requests made by different API keys.

Changes

  • Updated the @graphql-yoga/nestjs patch to include the request's Authorization header in the schema cache key generation logic.
  • This ensures that every unique authentication token (and thus every unique API key) generates a distinct cache entry, preventing schema context collisions.

Closes #15093

- Enhanced schema caching mechanism by including the authorization header in the cache key, improving cache hit accuracy.
- Updated related patch file and yarn.lock to reflect changes in dependencies and checksums.

This change optimizes the handling of GraphQL requests by ensuring that cached schemas are specific to user context, reducing unnecessary recomputation.
Copy link
Copy Markdown
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.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files


Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 9, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:62417

This environment will automatically shut down when the PR is closed or after 5 hours.

Copy link
Copy Markdown
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

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

@abdulrahmancodes thanks!

Question / feedbacks:

  1. Could you document how you were able to generate the patch, I was struggling with it last time I try, if you found a reliable way to generate it, that's great, we should document it somewhere :)
  2. I'm surprised about all the changes, I would expect that we just need to add the apiKeyId instead of workspaceUserId in the cacheKey.
  3. storing authHeader as cacheKey is a bad idea, security wise

@abdulrahmancodes
Copy link
Copy Markdown
Contributor Author

abdulrahmancodes commented Dec 9, 2025

@charlesBochet Thanks for the feedback.
I manually edited the patch file. The patch format is a standard git diff, so I located the cache key generation sections, added the authHeader extraction and included it in the cacheKey. Then I ran yarn to apply the patch and verify it worked. I wasn't aware of the autogeneration process

@socket-security
Copy link
Copy Markdown

socket-security bot commented Dec 10, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​ai-sdk/​react@​2.0.521001007399100
Added@​ai-sdk/​provider-utils@​3.0.9991007598100
Added@​ai-sdk/​xai@​2.0.191001008399100
Added@​ai-sdk/​anthropic@​2.0.171001008498100
Added@​ai-sdk/​openai@​2.0.301001008597100

View full report

@charlesBochet charlesBochet merged commit 289e8bf into main Dec 15, 2025
72 checks passed
@charlesBochet charlesBochet deleted the fix/graphql-schema-caching-api-keys branch December 15, 2025 17:23
@twenty-eng-sync
Copy link
Copy Markdown

Hey @charlesBochet! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

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.

Ex: when using several api keys, and creating objets, mix the API name

2 participants