Jelajahi Sumber

Refactoring

- NewProductTagConnection => NewStringConnection
Alexey Kim 2 tahun lalu
induk
melakukan
c77e1ec344
1 mengubah file dengan 4 tambahan dan 3 penghapusan
  1. 4 3
      graphql/helper/string_connection.go

+ 4 - 3
graphql/helper/product_tag.go → graphql/helper/string_connection.go

@@ -2,11 +2,12 @@ package helper
 
 import (
 	"github.com/gshopify/service-wrapper/fun"
+	"github.com/gshopify/service-wrapper/interfaces"
 	"github.com/gshopify/service-wrapper/model"
 	"gshopper.com/gshopify/products/graphql/generated"
 )
 
-func NewProductTagConnection(src []model.ProductTag,
+func NewStringConnection[T interfaces.Node](src []T,
 	first *int, last *int, reverse *bool) (*generated.StringConnection, error) {
 	var connection = &generated.StringConnection{}
 
@@ -25,8 +26,8 @@ func NewProductTagConnection(src []model.ProductTag,
 	// Edges
 	for i := range src {
 		connection.Edges = append(connection.Edges, &generated.StringEdge{
-			Cursor: *model.NewSimpleCursor(src[i].Tag).String(),
-			Node:   src[i].Tag,
+			Cursor: *model.NewSimpleCursor(src[i].GetID()).String(),
+			Node:   src[i].GetID(),
 		})
 	}