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
3 changes: 3 additions & 0 deletions v2/pkg/engine/plan/datasource_filter_visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ func (f *DataSourceFilter) applyLandedTo(landedTo map[int]DSHash) {

}

// collectNodes collects and organizes information about
// which data sources (subgraphs) can resolve each field and
// builds a "jump graph" to enable navigation between data sources using federation @key directives.
func (f *DataSourceFilter) collectNodes() {
if f.nodesCollector == nil {
f.nodesCollector = &nodesCollector{
Expand Down
9 changes: 5 additions & 4 deletions v2/pkg/engine/plan/node_selection_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ func (p *NodeSelectionBuilder) SelectNodes(operation, definition *ast.Document,
}

if p.config.Debug.PrintNodeSuggestions {
p.nodeSelectionsVisitor.nodeSuggestions.printNodesWithFilter("\nInitial node suggestions:\n", p.config.Debug.PrintNodeSuggestionsFilterNotSelected)
p.nodeSelectionsVisitor.nodeSuggestions.printNodesWithFilter("\nInitial node suggestions:\n",
p.config.Debug.PrintNodeSuggestionsFilterNotSelected)
}

p.nodeSelectionsVisitor.secondaryRun = false
Expand All @@ -126,10 +127,10 @@ func (p *NodeSelectionBuilder) SelectNodes(operation, definition *ast.Document,

i := 1
hasUnresolvedFields := false
// secondary runs to add path for the new required fields
// Additional runs to add paths for the new required fields
for p.nodeSelectionsVisitor.hasNewFields || hasUnresolvedFields {
// when we have rewritten a field old node suggestion are not make sense anymore
// so we are removing child nodes of the rewritten fields
// When we have rewritten a field, the old node suggestion does not make sense anymore:
// we have to remove child nodes of the rewritten fields.
for _, fieldRef := range p.nodeSelectionsVisitor.rewrittenFieldRefs {
p.nodeSelectionsVisitor.nodeSuggestions.RemoveTreeNodeChilds(fieldRef)
}
Expand Down
6 changes: 3 additions & 3 deletions v2/pkg/engine/plan/node_selection_visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
)

// nodeSelectionVisitor walks through the operation multiple times to rewrite it
// to be able to resolve fields from different datasources.
// This visitor might add required fields and rewrite abstract selection if necessary.
// to be able to resolve fields from different data sources.
// If necessary, this visitor might add required fields and rewrite abstract selections.
//
// This visitor will walk the operation again if it has:
// - added new required fields to the operation,
Expand Down Expand Up @@ -220,7 +220,7 @@ func (c *nodeSelectionVisitor) handleEnterField(fieldRef int, handleRequires boo
fieldAliasOrName := c.operation.FieldAliasOrNameString(fieldRef)
typeName := c.walker.EnclosingTypeDefinition.NameString(c.definition)

c.debugPrint("EnterField ref:", fieldRef, "fieldName:", fieldName, "typeName:", typeName)
c.debugPrint("EnterField ref:", fieldRef, "fieldName:", fieldName, "typeName:", typeName, "requires:", handleRequires)

parentPath := c.walker.Path.DotDelimitedString()
currentPath := parentPath + "." + fieldAliasOrName
Expand Down
2 changes: 1 addition & 1 deletion v2/pkg/engine/plan/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (p *Planner) Plan(operation, definition *ast.Document, operationName string
}

if p.config.Debug.PlanningVisitor {
debugMessage("Planning visitor:")
debugMessage("Planning Visitor\n================")
}

// configure planning visitor
Expand Down
12 changes: 6 additions & 6 deletions v2/pkg/engine/plan/visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ func (v *Visitor) debugOnEnterNode(kind ast.NodeKind, ref int) {
case ast.NodeKindField:
fieldName := v.Operation.FieldNameString(ref)
fullPath := v.currentFullPath(false)
v.debugPrint("EnterField : ", fieldName, " ref: ", ref, " path: ", fullPath)
v.debugPrint("EnterField:", fieldName, " ref:", ref, " path:", fullPath)
case ast.NodeKindInlineFragment:
fragmentTypeCondition := v.Operation.InlineFragmentTypeConditionNameString(ref)
v.debugPrint("EnterInlineFragment : ", fragmentTypeCondition, " ref: ", ref)
v.debugPrint("EnterInlineFragment:", fragmentTypeCondition, " ref:", ref)
case ast.NodeKindSelectionSet:
v.debugPrint("EnterSelectionSet", " ref: ", ref)
v.debugPrint("EnterSelectionSet", " ref:", ref)
}
}

Expand All @@ -98,12 +98,12 @@ func (v *Visitor) debugOnLeaveNode(kind ast.NodeKind, ref int) {
case ast.NodeKindField:
fieldName := v.Operation.FieldNameString(ref)
fullPath := v.currentFullPath(false)
v.debugPrint("LeaveField : ", fieldName, " ref: ", ref, " path: ", fullPath)
v.debugPrint("LeaveField:", fieldName, " ref:", ref, " path:", fullPath)
case ast.NodeKindInlineFragment:
fragmentTypeCondition := v.Operation.InlineFragmentTypeConditionNameString(ref)
v.debugPrint("LeaveInlineFragment : ", fragmentTypeCondition, " ref: ", ref)
v.debugPrint("LeaveInlineFragment:", fragmentTypeCondition, " ref:", ref)
case ast.NodeKindSelectionSet:
v.debugPrint("LeaveSelectionSet", " ref: ", ref)
v.debugPrint("LeaveSelectionSet", " ref:", ref)
}
}

Expand Down