Skip to content
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

Fix: broken namespace aliases and mutable selections #108

Merged
merged 1 commit into from
Nov 16, 2021
Merged
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
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