Skip to content

Separate normalized directive computation from ordinary lookup - #4560

Merged
andimarek merged 3 commits into
masterfrom
codex/lazy-normalized-directive-values
Nov 14, 2026
Merged

andimarek merged 3 commits into
masterfrom
codex/lazy-normalized-directive-values

Conversation

@andimarek

@andimarek andimarek commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Ordinary QueryDirectives lookups currently normalize the operation's variables and directive arguments as a side effect. A data fetcher asking for coerced directive values can therefore invoke custom scalar valueToLiteral() even though it never requests normalized values.

Separate the two lazy computations. Ordinary lookups resolve and cache directives using coerced variables. getNormalizedInputValueByImmediateAppliedDirectives() uses its own thread-safe memoized computation, reuses the resolved applied-directive instances, and requests normalized variables only when needed. Fields without directives return an empty normalized map without evaluating the variable supplier. A normalized conversion failure leaves ordinary directive values available.

Keep a direct applied-directive-to-AST map for later normalization, replacing the intermediate bidirectional maps. Preserve repeatable directive ordering and ordinary argument defaults. When directives are present but normalized variables are unavailable (including ENOF operations created from coerced variables), the normalized getter throws AssertException with a descriptive message instead of silently returning an empty map. This prevents the ENF-to-AST compiler from silently omitting directive arguments when normalization is unavailable. Ordinary directive lookups remain available. Correct the Javadoc that previously described normalized directive arguments as ENOF-only. Raw-variable ENOF creation itself continues to normalize variables as before.

Spock coverage checks all six ordinary getters, both lookup orders, cache and instance reuse, repeatable directives across merged fields, empty fields, literal arguments with the builder’s default empty variables, conversion failure isolation, unavailable normalized variables on the coerced-variable ENOF path, and a real execution path with a custom scalar. The seven targeted ordinary-lookup regression cases fail against the original implementation; the focused directive/normalized-operation suite passes with this change.

Full local Java 25 validation passed: ./gradlew assemble test testng check javadoc jacocoTestReport. The final builder test also passed in the focused suite. The assertion follow-up passed all 440 focused directive/normalized-operation tests and Javadoc. All 10 CI checks passed on the final commit, including the Java 17/21/25 test suites and per-class coverage gate. The coverage baseline is unchanged. No benchmark timing claim is made.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Test Report

Test Results

Java Version Total Passed Failed Errors Skipped
Java 17 6369 (+13 🟢) 6314 (+13 🟢) 0 (±0) 0 (±0) 55 (±0)
Java 21 6369 (+13 🟢) 6314 (+13 🟢) 0 (±0) 0 (±0) 55 (±0)
Java 25 6369 (+13 🟢) 6314 (+13 🟢) 0 (±0) 0 (±0) 55 (±0)
jcstress 32 (±0) 32 (±0) 0 (±0) 0 (±0) 0 (±0)
Total 19139 (+39 🟢) 18974 (+39 🟢) 0 (±0) 0 (±0) 165 (±0)

Code Coverage (Java 25)

Metric Covered Missed Coverage vs Master
Lines 26783 2698 90.8% ±0.0%
Branches 7681 1170 86.8% ±0.0%
Methods 7414 1091 87.2% ±0.0%

Changed Class Coverage (2 classes)

Class Line Branch Method
g.e.d.QueryDirectivesBuilder +10.0% 🟢 ±0.0% +11.1% 🟢
g.e.d.QueryDirectivesImpl +2.7% 🟢 +25.0% 🟢 +6.3% 🟢

Full HTML report: build artifact jacoco-html-report

Updated: 2026-11-14 21:35:40 UTC

@andimarek
andimarek merged commit a0ddff6 into master Nov 14, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant