GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing github.com — Add cheap field definition accessor to InstrumentationFieldFetchParameters by rhino88 · Pull Request #4544 · graphql-java/graphql-java Conversation
|
| Before | After | |
|---|---|---|
| Objects built | DataFetchingEnvironmentImpl, ExecutionStepInfo (via createExecutionStepInfo), argument/normalized field suppliers, DataFetchingFieldSelectionSetImpl, QueryDirectivesImpl |
none |
| Supplier invoked | yes (environment.get()) |
no |
| Result | executionStepInfo.get().getFieldDefinition() |
the GraphQLFieldDefinition fetchField already had |
So an instrumentation can now do GraphQLTypeUtil.isLeaf(parameters.getField().getType()) on every fetch for free, and only pay for the environment when it actually calls getEnvironment().
New Spock spec InstrumentationFieldFetchParametersTest:
getField() with a throwing environment Supplier returns the supplied definition and GraphQLTypeUtil.isLeaf works on it, proving the supplier is never invoked.InstrumentationFieldParameters with a throwing ExecutionStepInfo supplier.SimplePerformantInstrumentation reads parameters.getField() in beginFieldFetching against a real schema and sees the right leaf/non-leaf classification per field../gradlew test (JDK 25 toolchain):
6076 tests run in 290716 ms
BUILD SUCCESSFUL in 5m 1s
6076 tests, 7 skipped, 0 failures, 0 errors.
🤖 Generated with Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…eters InstrumentationFieldFetchParameters.getField() previously went through the ExecutionStepInfo supplier, which is backed by the lazily built DataFetchingEnvironment. Any instrumentation that only wanted the field definition in beginFieldFetching therefore paid for a DataFetchingEnvironmentImpl plus ExecutionStepInfo on every fetch, even for trivial PropertyDataFetcher fetches that never build the environment themselves. ExecutionStrategy.fetchField already resolves the GraphQLFieldDefinition eagerly, so pass it into the parameters and have getField() return it directly without touching the supplier. The existing public constructors are kept and delegate with a null field definition, which falls back to the supplier path. Motivated by apollographql/federation-jvm#469. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…docs The override in InstrumentationFieldFetchParameters only delegated to super and existed to carry Javadoc, so its guidance now lives on getEnvironment(). Also rename the misnamed getExecutionContext constructor parameter, keep the base class Javadoc to what it knows about (the ExecutionStepInfo supplier), and import ExecutionStepInfo in the test instead of using the fully-qualified name. Co-Authored-By: Claude Fable 5.1 <[email protected]>
The engine-level test now checks that beginFieldExecution and beginFieldFetching both receive the field definition eagerly, so it fails if ExecutionStrategy stops passing fieldDef. Previously it only checked getField() results, which were correct either way. Reword the getField() Javadoc to say the fallback reads the ExecutionStepInfo supplier, which is what the code has always done. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… into cheap-field-definition-accessor
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.