-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Stop creating NonNullableFieldValidator every for every object or list field #3929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -607,10 +607,7 @@ private FieldValueInfo completeField(GraphQLFieldDefinition fieldDef, ExecutionC | |
| instrumentationParams, executionContext.getInstrumentationState() | ||
| )); | ||
|
|
||
| NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext, executionStepInfo); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to recreate it |
||
|
|
||
| ExecutionStrategyParameters newParameters = parameters.transform(executionStepInfo, | ||
| nonNullableFieldValidator, | ||
| fetchedValue.getLocalContext(), | ||
| fetchedValue.getFetchedValue()); | ||
|
|
||
|
|
@@ -769,13 +766,12 @@ protected FieldValueInfo completeValueForList(ExecutionContext executionContext, | |
|
|
||
| ExecutionStepInfo stepInfoForListElement = executionStepInfoFactory.newExecutionStepInfoForListElement(executionStepInfo, indexedPath); | ||
|
|
||
| NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext, stepInfoForListElement); | ||
|
|
||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need - same reason |
||
| FetchedValue value = unboxPossibleDataFetcherResult(executionContext, parameters, item); | ||
|
|
||
| ExecutionStrategyParameters newParameters = parameters.transform(stepInfoForListElement, | ||
| nonNullableFieldValidator, indexedPath, | ||
| value.getLocalContext(), value.getFetchedValue()); | ||
| indexedPath, | ||
| value.getLocalContext(), | ||
| value.getFetchedValue()); | ||
|
|
||
| fieldValueInfos.add(completeValue(executionContext, newParameters)); | ||
| index++; | ||
|
|
@@ -914,10 +910,8 @@ protected Object completeValueForObject(ExecutionContext executionContext, Execu | |
| ); | ||
|
|
||
| ExecutionStepInfo newExecutionStepInfo = executionStepInfo.changeTypeWithPreservedNonNull(resolvedObjectType); | ||
| NonNullableFieldValidator nonNullableFieldValidator = new NonNullableFieldValidator(executionContext, newExecutionStepInfo); | ||
|
|
||
| ExecutionStrategyParameters newParameters = parameters.transform(newExecutionStepInfo, | ||
| nonNullableFieldValidator, | ||
| subFields, | ||
| result); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,7 +38,7 @@ private ExecutionStrategyParameters(ExecutionStepInfo executionStepInfo, | |
| this.localContext = localContext; | ||
| this.fields = assertNotNull(fields, () -> "fields is null"); | ||
| this.source = source; | ||
| this.nonNullableFieldValidator = nonNullableFieldValidator; | ||
| this.nonNullableFieldValidator = assertNotNull(nonNullableFieldValidator, () -> "requires a NonNullValidator");; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to be more specific - this helped find tests that "half create" objects for testing reasons |
||
| this.path = path; | ||
| this.currentField = currentField; | ||
| this.parent = parent; | ||
|
|
@@ -132,7 +132,6 @@ ExecutionStrategyParameters transform(MergedField currentField, | |
|
|
||
| @Internal | ||
| ExecutionStrategyParameters transform(ExecutionStepInfo executionStepInfo, | ||
| NonNullableFieldValidator nonNullableFieldValidator, | ||
| MergedSelectionSet fields, | ||
| Object source) { | ||
| return new ExecutionStrategyParameters(executionStepInfo, | ||
|
|
@@ -148,7 +147,6 @@ ExecutionStrategyParameters transform(ExecutionStepInfo executionStepInfo, | |
|
|
||
| @Internal | ||
| ExecutionStrategyParameters transform(ExecutionStepInfo executionStepInfo, | ||
| NonNullableFieldValidator nonNullableFieldValidator, | ||
| ResultPath path, | ||
| Object localContext, | ||
| Object source) { | ||
|
|
@@ -165,7 +163,6 @@ ExecutionStrategyParameters transform(ExecutionStepInfo executionStepInfo, | |
|
|
||
| @Internal | ||
| ExecutionStrategyParameters transform(ExecutionStepInfo executionStepInfo, | ||
| NonNullableFieldValidator nonNullableFieldValidator, | ||
| Object localContext, | ||
| Object source) { | ||
| return new ExecutionStrategyParameters(executionStepInfo, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,6 +117,7 @@ abstract class AsyncExecutionStrategyTest extends Specification { | |
| .newParameters() | ||
| .executionStepInfo(typeInfo) | ||
| .fields(mergedSelectionSet(['hello': mergedField([Field.newField('hello').build()]), 'hello2': mergedField([Field.newField('hello2').build()])])) | ||
| .nonNullFieldValidator(new NonNullableFieldValidator(executionContext)) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The rest of the changes are test fixups where they half create support objects with just enough brains to work |
||
| .build() | ||
|
|
||
| AsyncExecutionStrategy asyncExecutionStrategy = new AsyncExecutionStrategy() | ||
|
|
@@ -160,6 +161,7 @@ abstract class AsyncExecutionStrategyTest extends Specification { | |
| .newParameters() | ||
| .executionStepInfo(typeInfo) | ||
| .fields(mergedSelectionSet(['hello': mergedField([Field.newField('hello').build()]), 'hello2': mergedField([Field.newField('hello2').build()])])) | ||
| .nonNullFieldValidator(new NonNullableFieldValidator(executionContext)) | ||
| .build() | ||
|
|
||
| AsyncExecutionStrategy asyncExecutionStrategy = new AsyncExecutionStrategy() | ||
|
|
@@ -205,6 +207,7 @@ abstract class AsyncExecutionStrategyTest extends Specification { | |
| .newParameters() | ||
| .executionStepInfo(typeInfo) | ||
| .fields(mergedSelectionSet(['hello': mergedField([Field.newField('hello').build()]), 'hello2': mergedField([Field.newField('hello2').build()])])) | ||
| .nonNullFieldValidator(new NonNullableFieldValidator(executionContext)) | ||
| .build() | ||
|
|
||
| AsyncExecutionStrategy asyncExecutionStrategy = new AsyncExecutionStrategy() | ||
|
|
@@ -249,6 +252,7 @@ abstract class AsyncExecutionStrategyTest extends Specification { | |
| .newParameters() | ||
| .executionStepInfo(typeInfo) | ||
| .fields(mergedSelectionSet(['hello': mergedField([Field.newField('hello').build()]), 'hello2': mergedField([Field.newField('hello2').build()])])) | ||
| .nonNullFieldValidator(new NonNullableFieldValidator(executionContext)) | ||
| .build() | ||
|
|
||
| AsyncExecutionStrategy asyncExecutionStrategy = new AsyncExecutionStrategy() | ||
|
|
@@ -312,6 +316,7 @@ abstract class AsyncExecutionStrategyTest extends Specification { | |
| .newParameters() | ||
| .executionStepInfo(typeInfo) | ||
| .fields(mergedSelectionSet(['hello': mergedField([new Field('hello')]), 'hello2': mergedField([new Field('hello2')])])) | ||
| .nonNullFieldValidator(new NonNullableFieldValidator(executionContext)) | ||
| .build() | ||
|
|
||
| AsyncExecutionStrategy asyncExecutionStrategy = new AsyncExecutionStrategy() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the executionStepInfo here. Its passed in during
validateSo this instance gets used for the entirety of the operation