From 5036b7ffec59c1dc88d8e299bb03324936fb7b35 Mon Sep 17 00:00:00 2001 From: Adam Sven Johnson Date: Tue, 23 Apr 2024 11:02:56 +1200 Subject: [PATCH 1/2] Remove unused arguments from function calls --- merge.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/merge.go b/merge.go index 1922453c..6a660d5c 100644 --- a/merge.go +++ b/merge.go @@ -185,7 +185,7 @@ func mergeTypes(a, b map[string]*ast.Definition) (map[string]*ast.Definition, er continue } - mergedBoundaryObject, err := mergeBoundaryObjects(a, b, &newVB, va) + mergedBoundaryObject, err := mergeBoundaryObjects(&newVB, va) if err != nil { return nil, err } @@ -284,7 +284,7 @@ func mergeNamespaceObjects(aTypes, bTypes map[string]*ast.Definition, a, b *ast. }, nil } -func mergeBoundaryObjects(aTypes, bTypes map[string]*ast.Definition, a, b *ast.Definition) (*ast.Definition, error) { +func mergeBoundaryObjects(a, b *ast.Definition) (*ast.Definition, error) { result := &ast.Definition{ Kind: ast.Object, Description: mergeDescriptions(a, b), @@ -294,7 +294,7 @@ func mergeBoundaryObjects(aTypes, bTypes map[string]*ast.Definition, a, b *ast.D Fields: nil, } - mergedFields, err := mergeBoundaryObjectFields(aTypes, bTypes, a, b) + mergedFields, err := mergeBoundaryObjectFields(a, b) if err != nil { return nil, err } @@ -303,7 +303,7 @@ func mergeBoundaryObjects(aTypes, bTypes map[string]*ast.Definition, a, b *ast.D return result, nil } -func mergeBoundaryObjectFields(aTypes, bTypes map[string]*ast.Definition, a, b *ast.Definition) (ast.FieldList, error) { +func mergeBoundaryObjectFields(a, b *ast.Definition) (ast.FieldList, error) { var result ast.FieldList for _, f := range a.Fields { if isQueryType(a) && (isNodeField(f) || isServiceField(f)) { From 6abd85f3294709e26bf64fbd9513704abcc4e99b Mon Sep 17 00:00:00 2001 From: Adam Sven Johnson Date: Tue, 23 Apr 2024 11:03:57 +1200 Subject: [PATCH 2/2] Simplify function by merging fields first --- merge.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/merge.go b/merge.go index 6a660d5c..e9dcf9a0 100644 --- a/merge.go +++ b/merge.go @@ -285,22 +285,19 @@ func mergeNamespaceObjects(aTypes, bTypes map[string]*ast.Definition, a, b *ast. } func mergeBoundaryObjects(a, b *ast.Definition) (*ast.Definition, error) { - result := &ast.Definition{ - Kind: ast.Object, - Description: mergeDescriptions(a, b), - Name: a.Name, - Directives: a.Directives.ForNames(boundaryDirectiveName), - Interfaces: append(a.Interfaces, b.Interfaces...), - Fields: nil, - } - mergedFields, err := mergeBoundaryObjectFields(a, b) if err != nil { return nil, err } - result.Fields = mergedFields - return result, nil + return &ast.Definition{ + Kind: ast.Object, + Description: mergeDescriptions(a, b), + Name: a.Name, + Directives: a.Directives.ForNames(boundaryDirectiveName), + Interfaces: append(a.Interfaces, b.Interfaces...), + Fields: mergedFields, + }, nil } func mergeBoundaryObjectFields(a, b *ast.Definition) (ast.FieldList, error) {