Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
275 changes: 273 additions & 2 deletions execution/engine/execution_engine_grpc_requires_test.go

Large diffs are not rendered by default.

24 changes: 16 additions & 8 deletions v2/pkg/engine/datasource/grpc_datasource/execution_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,20 +921,26 @@ type fragmentSelection struct {
selectionSetRef int
}

// enterResolverCompositeSelectionSet handles logic when entering a composite selection set for a given field resolver.
// It appends the inline fragment selections to the resolved field and sets the fragment type.
func (r *rpcPlanningContext) enterResolverCompositeSelectionSet(oneOfType OneOfType, selectionSetRef int, resolvedField *resolverField) {
resolvedField.fieldsSelectionSetRef = ast.InvalidRef
resolvedField.fragmentType = oneOfType
type compositeTypeConfig struct {
oneOfType OneOfType
fieldsSelectionSetRef int
fragmentSelections []fragmentSelection
}

func (r *rpcPlanningContext) buildCompositeTypeConfig(oneOfType OneOfType, selectionSetRef int) compositeTypeConfig {
config := compositeTypeConfig{
oneOfType: oneOfType,
fieldsSelectionSetRef: ast.InvalidRef,
}

// In case of an interface we can select individual fields from the interface without having to use an inline fragment.
if len(r.operation.SelectionSetFieldRefs(selectionSetRef)) > 0 {
resolvedField.fieldsSelectionSetRef = selectionSetRef
config.fieldsSelectionSetRef = selectionSetRef
}

inlineFragSelections := r.operation.SelectionSetInlineFragmentSelections(selectionSetRef)
if len(inlineFragSelections) == 0 {
return
return config
}

for _, inlineFragSelectionRef := range inlineFragSelections {
Expand All @@ -944,11 +950,13 @@ func (r *rpcPlanningContext) enterResolverCompositeSelectionSet(oneOfType OneOfT
continue
}

resolvedField.fragmentSelections = append(resolvedField.fragmentSelections, fragmentSelection{
config.fragmentSelections = append(config.fragmentSelections, fragmentSelection{
typeName: r.operation.InlineFragmentTypeConditionNameString(inlineFragRef),
selectionSetRef: inlinFragSelectionSetRef,
})
}

return config
}

// isFieldResolver checks if a field is a field resolver.
Expand Down
Loading
Loading