Repository navigation
refactor!: one GraphQL row-cost model, typed errors, one executor - #341
Merged
Merged
Conversation
Row budget is the product of resolved page limits, checked per root field against max_rows before SQL runs; engine and CLI share the cost functions. CompileError/ExecuteError replace substring classification. One execute_plan generic over the backend: Postgres opens the read-only transaction and sets the timeout in one round trip (5 -> 3 per root field). GraphqlEngine::plan replaces sentinel-error plan capture; PROOF_TABLES comes from the projection store; manifests are borrowed on request paths; the root_field metric label is the schema field. BREAKING CHANGE: max_complexity becomes max_fields and max_rows (default 200,000) is new; the manifest execution shape and every schema fingerprint change; "query too complex" is now "row budget exceeded"; client_application_surface_with_schema_roles and surface_for_application_contract are renamed; graphql_sdl_from_schemas and core_sdl_for_catalog are removed. Implements [[tasks/v5-review-26]]
…v5-review-26a-query-cost
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
patrickleet
changed the base branch from
refactor/v5-review-25d-gateway-delivery
to
v5
November 25, 2026 00:25
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.
Task 26 stage A ([[tasks/v5-review-26]]): the query side. Stacked on #340. Live-delivery sharing is stage B.
What changed
src/graphql/cost.rs,docs/graphql-query-cost.md):limit × (1 + rows nested under one row), using each list's resolved limit. One object costs1 + nested.max_rowsbefore any SQL runs. Arithmetic saturates.max_depth,max_fields,max_rows, page limits, list widths, timeout.d8_explicit_limits_multiply_into_the_row_budget:1000×1000is refused, while1000×199(exactly 200,000) is admitted. The old fixed fan-out of 5 ignoredlimit.CompileError(TooDeep, TooManyRows, ListTooLong, InvalidResponseKey, InvalidFilter, UnsupportedOnCellStore, BadRequest, Internal) andExecuteError(Timeout, Failed) replace substring classification.compile_client_wherereturnsOption.execute_planis generic over aGraphqlBackend(begin_read,fetch,gateway_versions) and replaces the four arms. Plans are held inArc.BEGIN … READ ONLY; SET LOCAL statement_timeoutas one message.log_statement=all): 4 → 3 withoutgateway, 5 → 3 with it.REPEATABLE READ READ ONLY.GraphqlEngine::plan(..)with a typedPlanRecorderreplaces the sentinel-error capture.PROOF_TABLESis exported by the projection store, tested against both migration directories. SQLite now includes its own migration.VersionErrorenum.root_fieldmetric label is the schema field, not the alias.Decision to confirm
The default
max_rowsis 200,000. At 20,000 an existing test (siblingchildren+children_aggregate.nodeslists) was refused. At 200,000 the limit still refuses nested lists at the maximum page size (1,001,000) and two default-sized nested levels (1,010,100). It is one constant.Breaking changes
max_complexitybecomesmax_fields;max_rowsis new.executionshape changed (ClientComplexityWeightsis gone), so every schema fingerprint changes. In the CLI goldens only theschemaHashlines differ.client_application_surface_with_schema_roles→client_application_surface,surface_for_application_contract→surface_for_application.graphql_sdl_from_schemas,core_sdl_for_catalog, and the plan-capture types.INTERNAL.Tests
Run locally:
cargo test --workspace --all-featureswith Postgres: passes (distributedlib 1,227).tests/gateway-postgres/run.py(primary/standby): pass.--include-ignored: 342 passed, 0 failed (rerun by me).Not done
query_protocol.rs/schema.rssplits and shared SDL helpers.GraphqlEngine::plan; gateway delivery tests cover it.