Commit 9511d2d
review: address ysmolski + CodeRabbit feedback on #1259
Applies the accepted set of review items from docs/pr1259-review/TODO.md.
ysmolski (planner / visitor.go):
- A25: drop the redundant (v.planners == nil || plannerID >= len) guard in
trackFieldForPlanner — shouldPlannerHandleField already checks bounds.
- A33: comment the EnterDocument reset block so the per-walk reset lifecycle
is explicit next to the fieldPlanners-not-reset note.
- A34: trim the backwards "non-key fields on concrete entity types" comment
into a single, forward-reading line.
- A35: remove the vestigial `typeName != ""` guard inside the object-type
branch of the CacheAnalytics switch.
- A36: extract polymorphicEntityCacheAnalytics so the union/interface arm
no longer needs a hasEntity flag and duplicate inner switch.
- A37: tighten the "Initialize per-planner structures" comment.
- A39: drop the unused nil-check at the top of initializePlannerStructures.
- A40: document why createFieldValueForPlanner doesn't reuse resolveFieldValue
(no walker-state mutation so it is callable from EnterField).
- A41: note that plannerResponsePaths / plannerEntityBoundaryPaths are stored
normalized (fragment markers stripped).
- A42: normalize fullFieldPath in isEntityRootField before the HasPrefix
comparison and extract isEntityRootPath as a pure helper.
Inline-fragment queries (e.g. `... on User { reviews }`) previously broke
entity-root detection because the walker path still carried `$N<TypeName>`
markers while the boundary path was already normalized.
Adds visitor_path_normalization_test.go with TestIsEntityRootPath covering
fragment-wrapped boundary paths and TestNormalizePathRemovingFragments
locking the regex invariant.
- A44: rewrite the entityKeyFieldNames doc without double-negation; flag the
compound-key limitation (whitespace splitting produces a superset that
widens key-field detection, falling into the safer no-op branch rather
than over-invalidating).
- A45: iterate fieldEnclosingTypeNames in subscriptionSelectsNonKeyFields
instead of every operation field ref.
- A46: merge resolveUnionEntityPopulation and resolveInterfaceEntityPopulation
into a single resolveAbstractEntityPopulation helper that handles both
union members and interface implementors.
- A47: drop the unused fieldRef parameter from createFieldValueForPlanner.
- A48: in configureMutationEntityImpact, merge keys from ALL @key configs via
extractKeyFields instead of reading only keyConfigs[0] — entities with
multiple @key directives no longer lose invalidation-relevant fields.
- A28 / A29 / A32: delete the unused relatedUsers field (regenerate gqlgen
output), drop redundant `IncludeSubgraphHeaderPrefix: false` lines in
federation_caching_test.go, and remove the unused
WithRootFieldEntityCacheKeyTemplates testing option.
A49 (reverse-index optimization for trackFieldForPlanner) was attempted and
reverted — planningVisitor is registered on the walker before individual
planner visitors, so AllowVisitor fires for planners after planningVisitor.EnterField
runs. fieldPlanners[ref] is still empty at that point, which broke datasource
tests (TestGraphQLDataSource/simple_named_Query_with_field_info and
composite_keys_with_info/run) with missing ProvidesData fields. The O(planners)
loop remains, with shouldPlannerHandleField short-circuiting non-owning
planners. A49 is now tracked as a follow-up in TODO.md.
CodeRabbit (test robustness and fixtures):
- B02: close the original req.Body and surface the io.ReadAll error in
partial_cache_test.go subgraphRequestTracker.RoundTrip.
- B03: route MeInterface / MeUnion / Identifiable resolvers through
GetUsername(id) so UpdateUsername is reflected in those paths too.
- B05: confirmed all subscription channel sends in products/schema.resolvers.go
are already wrapped in `select { <-ctx.Done() / ch <- p }` — no change
needed.
- B11+C07: broaden the CacheEntry.Value description to opaque bytes
(entity JSON or root-field response bytes).
- B13: populate Nickname and RealName on the User returned by
UpdateUsername (match the Me/User resolver pattern).
- B14: accept first=0 in products/UpdatedPrices (guard changed from `> 0`
to `>= 0`).
- B15+C08: document the full L2 key transformation pipeline (GlobalCacheKeyPrefix
→ subgraph header prefix → L2CacheKeyInterceptor) in both the main
"Key Transformations" section and the extension-invalidation step list.
- B17: create a fresh FakeLoaderCache inside each parallel subtest in
TestFakeLoaderCache to eliminate TTL cross-contamination.
- B18: bound raw `<-messages` receives in federation_subscription_caching_test.go
via a mustRecvMessage(t, ch, 5s) helper.
- B19: configure a matching Subscription.updateProductPrice root-field cache
in the negative test so it actually exercises the "subscription roots
ignore matching root-field cache" path, and assert the subscription-root
cache key never appears.
- B20: harden shared-trigger receive loops with readOrFail semantics
(`m, ok := <-ch`) and mirror the warm-up pattern to both 2-client blocks.
- C01: drop `.serena` from .gitignore (personal tool artifact).
- C02: extract executeQuery helper in graphql_client_test.go to de-duplicate
the four Query/QueryWithHeaders/QueryString/QueryStringWithHeaders flows.
- C03: normalize indentation in multiple_upstream_without_provides.query.
- C04: rename the inconsistent gatewayOptions.withLoaderCache field to
loaderCache to match sibling naming and avoid the option-builder collision.
- C05 already in tree: each gzip/deflate subtest already uses its own local
headers map; no change needed.
- C11: require.NoError every ignored url.Parse in
federation_caching_root_entity_test.go (5 sites).
- C13: wrap the two `<-message` receives in federation_integration_static_test.go
with the mustRecvMessage helper.
Docs / review artifacts:
- docs/pr1259-review/ — FEEDBACK.md (raw PR comments, H2 per item),
CLAUDE_EVAL.md, CODEX_EVAL.md, and TODO.md (reconciled joint decisions).
Joint evaluations reached agreement before code changes; re-review after
applying changes surfaced three follow-ups (A42 test coverage, B15+C08
second doc reference, C11 remaining sites) which are also addressed in
this commit.
Validation:
- `go test ./...` green for both the v2/ and execution/ modules.
- New tests: TestIsEntityRootPath, TestNormalizePathRemovingFragments,
TestVisitorEntityKeyFieldNames.
- Codex code-review sign-off on the final diff.
Also bundled:
- v2/pkg/engine/resolve/cache_analytics.go / context.go — sync.Pool for
CacheAnalyticsCollector (pre-existing branch-local perf work;
AcquireCacheAnalyticsCollector / ReleaseCacheAnalyticsCollector / ResetForReuse).
- v2/pkg/engine/plan/visitor_subscription_entity_population_test.go —
entityKeyFieldNames unit tests (pre-existing branch-local).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 53e0625 commit 9511d2d
26 files changed
Lines changed: 3568 additions & 461 deletions
File tree
- docs
- entity-caching
- pr1259-review
- execution
- engine
- federationtesting
- accounts/graph
- generated
- model
- products/graph
- testdata/queries
- v2/pkg/engine
- datasourcetesting
- plan
- resolve
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
328 | | - | |
| 328 | + | |
329 | 329 | | |
330 | | - | |
| 330 | + | |
331 | 331 | | |
332 | 332 | | |
333 | | - | |
| 333 | + | |
334 | 334 | | |
335 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
336 | 341 | | |
337 | 342 | | |
338 | 343 | | |
| |||
553 | 558 | | |
554 | 559 | | |
555 | 560 | | |
556 | | - | |
| 561 | + | |
557 | 562 | | |
558 | 563 | | |
559 | 564 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
0 commit comments