Skip to content

Commit

Permalink
Rename getOrCreateField to getOrCreateAndAppendField to describe beha…
Browse files Browse the repository at this point in the history
…viour
  • Loading branch information
asp24 authored and asp24 committed Apr 17, 2019
1 parent a74abc4 commit 88cdbdf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions graphql/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func collectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies []
if !shouldIncludeNode(sel.Directives, reqCtx.Variables) {
continue
}
f := getOrCreateField(&groupedFields, sel.Alias, func() CollectedField {
f := getOrCreateAndAppendField(&groupedFields, sel.Alias, func() CollectedField {
return CollectedField{Field: sel}
})

Expand All @@ -45,7 +45,7 @@ func collectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies []
continue
}
for _, childField := range collectFields(reqCtx, sel.SelectionSet, satisfies, visited) {
f := getOrCreateField(&groupedFields, childField.Name, func() CollectedField { return childField })
f := getOrCreateAndAppendField(&groupedFields, childField.Name, func() CollectedField { return childField })
f.Selections = append(f.Selections, childField.Selections...)
}

Expand All @@ -70,7 +70,7 @@ func collectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies []
}

for _, childField := range collectFields(reqCtx, fragment.SelectionSet, satisfies, visited) {
f := getOrCreateField(&groupedFields, childField.Name, func() CollectedField { return childField })
f := getOrCreateAndAppendField(&groupedFields, childField.Name, func() CollectedField { return childField })
f.Selections = append(f.Selections, childField.Selections...)
}

Expand All @@ -97,7 +97,7 @@ func instanceOf(val string, satisfies []string) bool {
return false
}

func getOrCreateField(c *[]CollectedField, name string, creator func() CollectedField) *CollectedField {
func getOrCreateAndAppendField(c *[]CollectedField, name string, creator func() CollectedField) *CollectedField {
for i, cf := range *c {
if cf.Alias == name {
return &(*c)[i]
Expand Down

0 comments on commit 88cdbdf

Please sign in to comment.