Conversation
| ResultPath path = ResultPath.rootPath(); | ||
| ExecutionStepInfo executionStepInfo = newExecutionStepInfo().type(operationRootType).path(path).build(); | ||
| NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext, executionStepInfo); | ||
| NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext); |
There was a problem hiding this comment.
No need for the executionStepInfo here. Its passed in during validate
So this instance gets used for the entirety of the operation
| instrumentationParams, executionContext.getInstrumentationState() | ||
| )); | ||
|
|
||
| NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext, executionStepInfo); |
There was a problem hiding this comment.
no need to recreate it
| NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext, executionStepInfo); | ||
|
|
||
| ExecutionStrategyParameters newParameters = parameters.transform(builder -> | ||
| builder.executionStepInfo(executionStepInfo) |
There was a problem hiding this comment.
see - executionStepInfo is in the ExecutionStrategyParameters always
| ExecutionStepInfo stepInfoForListElement = executionStepInfoFactory.newExecutionStepInfoForListElement(executionStepInfo, indexedPath); | ||
|
|
||
| NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext, stepInfoForListElement); | ||
|
|
| this.fields = assertNotNull(fields, () -> "fields is null"); | ||
| this.source = source; | ||
| this.nonNullableFieldValidator = nonNullableFieldValidator; | ||
| this.nonNullableFieldValidator = assertNotNull(nonNullableFieldValidator, () -> "requires a NonNullValidator");; |
There was a problem hiding this comment.
Just to be more specific - this helped find tests that "half create" objects for testing reasons
| return parameters.transform(builder -> builder.field(firstField).path(fieldPath)); | ||
| NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext); | ||
| return parameters.transform(builder -> | ||
| builder.field(firstField).path(fieldPath).nonNullFieldValidator(nonNullableFieldValidator)); |
There was a problem hiding this comment.
Subscriptions is a special case - because it starts a new ExecutionContext instance - So we do re-create it here - but only once - not per published message
| .newParameters() | ||
| .executionStepInfo(typeInfo) | ||
| .fields(mergedSelectionSet(['hello': mergedField([Field.newField('hello').build()]), 'hello2': mergedField([Field.newField('hello2').build()])])) | ||
| .nonNullFieldValidator(new NonNullableFieldValidator(executionContext)) |
There was a problem hiding this comment.
The rest of the changes are test fixups where they half create support objects with just enough brains to work
Test Results 314 files ±0 314 suites ±0 52s ⏱️ -2s Results for commit 80f4a3b. ± Comparison against base commit 397c050. This pull request removes 174 and adds 152 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
…ullableFieldValidator-all-the-time # Conflicts: # src/main/java/graphql/execution/ExecutionStrategy.java # src/main/java/graphql/execution/SubscriptionExecutionStrategy.java
Today we create a NonNullableFieldValidator for every list item and every object we encounter. We do this because the constructor took a ExecutionStepInfo which IF there was a problem was used say what field was in error
BUT we dont need this. It is passed into the
validatemethod via the ExecutionStrategyParameters anywaySo we can create 1 at execution time and use it through out
This save nemory allocation for cases where you have lots of object fields and / or lost of list fields.
This is NOT a breaking change - NonNullableFieldValidator is a internal class and this only changes the constructor shape