Browse Source

Cursor

- refactoring
Alexey Kim 2 years ago
parent
commit
bd2db98f12

+ 1 - 1
graphql/helper/collection.go

@@ -43,7 +43,7 @@ func NewCollectionConnection(src []*generated.Collection,
 			Node: connection.Nodes[i],
 		}
 
-		if c, err := model.NewSimpleCursor(e.Node.ID, model.GidCollection); err == nil {
+		if c, err := model.NewCursor(e.Node.ID, model.GidCollection); err == nil {
 			e.Cursor = *c.String()
 		}
 

+ 1 - 1
graphql/helper/product.go

@@ -45,7 +45,7 @@ func NewProductConnection(src []*generated.Product,
 			Node: connection.Nodes[i],
 		}
 
-		if c, err := model.NewSimpleCursor(e.Node.ID, model.GidProduct); err == nil {
+		if c, err := model.NewCursor(e.Node.ID, model.GidProduct); err == nil {
 			e.Cursor = *c.String()
 		}
 

+ 4 - 9
graphql/helper/product_tag.go

@@ -24,15 +24,10 @@ func NewProductTagConnection(src []model.ProductTag,
 
 	// Edges
 	for i := range src {
-		e := &generated.StringEdge{
-			Node: src[i].Tag,
-		}
-
-		if c, err := model.NewSimpleCursor(src[i].Tag, ""); err == nil {
-			e.Cursor = *c.String()
-		}
-
-		connection.Edges = append(connection.Edges, e)
+		connection.Edges = append(connection.Edges, &generated.StringEdge{
+			Cursor: *model.NewSimpleCursor(src[i].Tag).String(),
+			Node:   src[i].Tag,
+		})
 	}
 
 	return connection, nil

+ 1 - 1
graphql/helper/product_variant.go

@@ -76,7 +76,7 @@ func NewProductVariantConnection(src []*generated.ProductVariant,
 			Node: connection.Nodes[i],
 		}
 
-		if c, err := model.NewSimpleCursor(e.Node.ID, model.GidVariant); err == nil {
+		if c, err := model.NewCursor(e.Node.ID, model.GidVariant); err == nil {
 			e.Cursor = *c.String()
 		}