Skip to content

Commit

Permalink
Merge pull request #108 from gmac/fix-namespace-alias
Browse files Browse the repository at this point in the history
Fix: broken namespace aliases and mutable selections
  • Loading branch information
Lucian Jones authored Nov 16, 2021
2 parents 1b2caac + 81cb6ac commit 4b3dd2e
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,15 @@ func extractSelectionSet(ctx *PlanningContext, insertionPoint []string, parentTy
continue
}
loc, err := ctx.Locations.URLFor(parentType, location, selection.Name)
if err != nil {
// namespace
subSS, steps, err := extractSelectionSet(ctx, append(insertionPoint, selection.Name), selection.Definition.Type.Name(), selection.SelectionSet, location)
if err != nil {
return nil, nil, err
}
selection.SelectionSet = subSS
selectionSetResult = append(selectionSetResult, selection)
childrenStepsResult = append(childrenStepsResult, steps...)
continue
}
if loc != location {
// Errors are returned for unmapped namespace/interface locations (needs refactor)
if err == nil && loc != location {
// field transitions to another service location
remoteSelections = append(remoteSelections, selection)
} else if selection.SelectionSet == nil {
// field is a leaf type in the current service
selectionSetResult = append(selectionSetResult, selection)
} else {
// field is a composite type in the current service
newField := *selection
selectionSet, childrenSteps, err := extractSelectionSet(
ctx,
append(insertionPoint, selection.Alias),
Expand All @@ -168,6 +157,7 @@ func extractSelectionSet(ctx *PlanningContext, insertionPoint []string, parentTy
if err != nil {
return nil, nil, err
}
newField := *selection
newField.SelectionSet = selectionSet
selectionSetResult = append(selectionSetResult, &newField)
childrenStepsResult = append(childrenStepsResult, childrenSteps...)
Expand Down

0 comments on commit 4b3dd2e

Please sign in to comment.