Repository navigation
Require a batchKey on GraphQLResolver when the method needs services - #9045
Merged
Merged
Conversation
|
| Name | Type |
|---|---|
| effect | Patch |
| @effect/opentelemetry | Patch |
| @effect/vitest | Patch |
| @effect/ai-anthropic | Patch |
| @effect/ai-cloudflare | Patch |
| @effect/ai-openai-compat | Patch |
| @effect/ai-openai | Patch |
| @effect/ai-openrouter | Patch |
| @effect/ai-typesafe | Patch |
| @effect/atom-react | Patch |
| @effect/atom-solid | Patch |
| @effect/atom-vue | Patch |
| @effect/platform-browser | Patch |
| @effect/platform-bun | Patch |
| @effect/platform-deno | Patch |
| @effect/platform-node-shared | Patch |
| @effect/platform-node | Patch |
| @effect/sql-clickhouse | Patch |
| @effect/sql-d1 | Patch |
| @effect/sql-libsql | Patch |
| @effect/sql-mssql | Patch |
| @effect/sql-mysql2 | Patch |
| @effect/sql-pg | Patch |
| @effect/sql-pglite | Patch |
| @effect/sql-sqlite-bun | Patch |
| @effect/sql-sqlite-do | Patch |
| @effect/sql-sqlite-node | Patch |
| @effect/sql-sqlite-react-native | Patch |
| @effect/sql-sqlite-wasm | Patch |
| @effect/docgen | Patch |
| @effect/doctest | Patch |
| @effect/graphql-generator | Patch |
| @effect/openapi-generator | Patch |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
tim-smart
force-pushed
the
feat/graphql
branch
from
October 12, 2026 03:00
cbe82e6 to
506f923
Compare
Tenant-split batching at runtime and the batchKey type contract. Implementation follows separately.
A batch runs with one lookup's services, so lookups for different tenants could go out under the first tenant's token. ordered and findById now take a batchKey, required when GraphQL.Services<Op> is not never, and group batches by it with RequestResolver.makeGrouped.
tim-smart
force-pushed
the
agent/nelson/0064945be2a4
branch
from
October 12, 2026 03:05
f120d5a to
cdeabd2
Compare
tim-smart
added a commit
that referenced
this pull request
Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
GraphQLResolverran every batch with the first lookup's context. A middleware that reads a per-call service, such as aCurrentUsertoken, sent the whole batch under the first user's credentials, so lookups from two tenants in one batch leaked across.orderedandfindByIdnow take abatchKey: (context: Context<GraphQL.Services<Op>>) => unknown. It's required whenGraphQL.Services<Op>isn'tneverand rejected when it is. When given, the resolver is built withRequestResolver.makeGrouped, so each batch holds lookups with keys that are equal underEqual, and the first entry's context is correct for the whole batch. Without services, there's still one global batch.The JSDoc explains why you shouldn't key on the whole context (it holds the caller's span). It also notes the hole that's left: a middleware reading a
Context.Referencewith a default value doesn't show up inServices. The generator README batching section,ai-docs/src/52_graphql/30_batching.tsand thegraphql-clientchangeset are updated.Dependency
Builds on #9041 ("Fix grouped RequestResolver batch key retention"), which
feat/graphqlnow includes. Without it,makeGroupedwould keep every per-tenant key forever.Tests
Bearer awith R_1 and R_3, andBearer bwith R_2.requires,orderedandfindByIdwithoutbatchKeydon't compile. Without services,batchKeyisn't accepted.Validation
pnpm check,pnpm lint,pnpm jsdocs --check,pnpm test --runforpackages/effect/test/graphql/,packages/effect/test/RequestResolver.test.tsandpackages/tools/graphql-generator/test/,pnpm test-types graphql, andpnpm doctest --runforGraphQLResolver.tsandRequestResolver.tsall pass.Closes EFF-2004