Fix hydration selection set on nested input objects - #707
Conversation
854f7fa to
f835bab
Compare
| aliasHelper.toArtificial(it) | ||
| } | ||
| .toList() | ||
| } |
There was a problem hiding this comment.
New code here, the ENFs are built during validation time, now we just insert them from the instruction.
| deferSupport = nadelExecutionHints.deferSupport | ||
| shortCircuitEmptyQuery = nadelExecutionHints.shortCircuitEmptyQuery | ||
| sharedTypeRenames = nadelExecutionHints.sharedTypeRenames | ||
| virtualTypeSupport = nadelExecutionHints.virtualTypeSupport |
| | } | ||
| | batch_hydration__related__relatedIds: relatedIds { | ||
| | issueId | ||
| | projectId |
There was a problem hiding this comment.
The way these fields are generated was changed, now it's merged together which should be better.
Should execute the same way since fields would be merged at execution time.
| open fun makeExecutionHints(): NadelExecutionHints.Builder { | ||
| return NadelExecutionHints.Builder() | ||
| .hydrationFilterObjectTypes { true } | ||
| .hydrationExecutableSourceFields { true } |
There was a problem hiding this comment.
Test have new source fields code on by default.
| * This can be the fields described in [NadelHydrationArgument.ValueSource.FieldResultValue.queryPathToField] | ||
| * or [NadelBatchHydrationMatchStrategy.MatchObjectIdentifier.sourceId]. | ||
| */ | ||
| val executableSourceFields: List<ExecutableNormalizedField> |
There was a problem hiding this comment.
We now build the entire ExecutableNormalizedField ahead of time instead of just computing the required NadelQueryPath
| artificialFields = state.instructionsByObjectTypeNames | ||
| .flatMap { (objectTypeName, instructions) -> | ||
| NadelHydrationFieldsBuilder.makeRequiredSourceFields( | ||
| hints = executionContext.hints, |
| val hydrationSourceType = hydrationValueSource.fieldDefinition.type.unwrapAll() | ||
|
|
||
| if (hydrationSourceType is GraphQLObjectType) { | ||
| return createObjectField(argument, hydrationValueSource) |
There was a problem hiding this comment.
This is the main change, before this was
Which only selected one level of children.
Now it iterates through the required input object fields and then creates the selection set from that. It does this recursively to create the correct selection set.
Refer to the
test/src/test/kotlin/graphql/nadel/tests/next/fixtures/hydration/HydrationNestedObjectInputTest.kttest.Effectively when the user sets up a hydration
and
We need to ensure the selection set is
whereas it's currently
as we don't handle nested selection sets.
Also refactored it to create the ENFs ahead of time during validation.