aboutsummaryrefslogtreecommitdiffstats
path: root/graphql/connections
diff options
context:
space:
mode:
Diffstat (limited to 'graphql/connections')
-rw-r--r--graphql/connections/connection_template.go122
-rw-r--r--graphql/connections/connections.go45
-rw-r--r--graphql/connections/edges.go25
-rw-r--r--graphql/connections/gen_comment.go113
-rw-r--r--graphql/connections/gen_identity.go112
-rw-r--r--graphql/connections/gen_label.go113
-rw-r--r--graphql/connections/gen_lazy_bug.go113
-rw-r--r--graphql/connections/gen_lazy_identity.go113
-rw-r--r--graphql/connections/gen_operation.go113
-rw-r--r--graphql/connections/gen_timeline.go113
10 files changed, 0 insertions, 982 deletions
diff --git a/graphql/connections/connection_template.go b/graphql/connections/connection_template.go
deleted file mode 100644
index f276b2d0..00000000
--- a/graphql/connections/connection_template.go
+++ /dev/null
@@ -1,122 +0,0 @@
-package connections
-
-import (
- "fmt"
-
- "github.com/cheekybits/genny/generic"
-
- "github.com/MichaelMure/git-bug/graphql/models"
-)
-
-// Name define the name of the connection
-type Name generic.Type
-
-// NodeType define the node type handled by this relay connection
-type NodeType generic.Type
-
-// EdgeType define the edge type handled by this relay connection
-type EdgeType generic.Type
-
-// ConnectionType define the connection type handled by this relay connection
-type ConnectionType generic.Type
-
-// NodeTypeEdgeMaker define a function that take a NodeType and an offset and
-// create an Edge.
-type NameEdgeMaker func(value NodeType, offset int) Edge
-
-// NameConMaker define a function that create a ConnectionType
-type NameConMaker func(
- edges []*EdgeType,
- nodes []NodeType,
- info *models.PageInfo,
- totalCount int) (*ConnectionType, error)
-
-// NameCon will paginate a source according to the input of a relay connection
-func NameCon(source []NodeType, edgeMaker NameEdgeMaker, conMaker NameConMaker, input models.ConnectionInput) (*ConnectionType, error) {
- var nodes []NodeType
- var edges []*EdgeType
- var cursors []string
- var pageInfo = &models.PageInfo{}
- var totalCount = len(source)
-
- emptyCon, _ := conMaker(edges, nodes, pageInfo, 0)
-
- offset := 0
-
- if input.After != nil {
- for i, value := range source {
- edge := edgeMaker(value, i)
- if edge.GetCursor() == *input.After {
- // remove all previous element including the "after" one
- source = source[i+1:]
- offset = i + 1
- pageInfo.HasPreviousPage = true
- break
- }
- }
- }
-
- if input.Before != nil {
- for i, value := range source {
- edge := edgeMaker(value, i+offset)
-
- if edge.GetCursor() == *input.Before {
- // remove all after element including the "before" one
- pageInfo.HasNextPage = true
- break
- }
-
- e := edge.(EdgeType)
- edges = append(edges, &e)
- cursors = append(cursors, edge.GetCursor())
- nodes = append(nodes, value)
- }
- } else {
- edges = make([]*EdgeType, len(source))
- cursors = make([]string, len(source))
- nodes = source
-
- for i, value := range source {
- edge := edgeMaker(value, i+offset)
- e := edge.(EdgeType)
- edges[i] = &e
- cursors[i] = edge.GetCursor()
- }
- }
-
- if input.First != nil {
- if *input.First < 0 {
- return emptyCon, fmt.Errorf("first less than zero")
- }
-
- if len(edges) > *input.First {
- // Slice result to be of length first by removing edges from the end
- edges = edges[:*input.First]
- cursors = cursors[:*input.First]
- nodes = nodes[:*input.First]
- pageInfo.HasNextPage = true
- }
- }
-
- if input.Last != nil {
- if *input.Last < 0 {
- return emptyCon, fmt.Errorf("last less than zero")
- }
-
- if len(edges) > *input.Last {
- // Slice result to be of length last by removing edges from the start
- edges = edges[len(edges)-*input.Last:]
- cursors = cursors[len(cursors)-*input.Last:]
- nodes = nodes[len(nodes)-*input.Last:]
- pageInfo.HasPreviousPage = true
- }
- }
-
- // Fill up pageInfo cursors
- if len(cursors) > 0 {
- pageInfo.StartCursor = cursors[0]
- pageInfo.EndCursor = cursors[len(cursors)-1]
- }
-
- return conMaker(edges, nodes, pageInfo, totalCount)
-}
diff --git a/graphql/connections/connections.go b/graphql/connections/connections.go
deleted file mode 100644
index 0083f8b2..00000000
--- a/graphql/connections/connections.go
+++ /dev/null
@@ -1,45 +0,0 @@
-//go:generate genny -in=connection_template.go -out=gen_lazy_bug.go gen "Name=LazyBug NodeType=entity.Id EdgeType=LazyBugEdge ConnectionType=models.BugConnection"
-//go:generate genny -in=connection_template.go -out=gen_lazy_identity.go gen "Name=LazyIdentity NodeType=entity.Id EdgeType=LazyIdentityEdge ConnectionType=models.IdentityConnection"
-//go:generate genny -in=connection_template.go -out=gen_identity.go gen "Name=Identity NodeType=models.IdentityWrapper EdgeType=models.IdentityEdge ConnectionType=models.IdentityConnection"
-//go:generate genny -in=connection_template.go -out=gen_operation.go gen "Name=Operation NodeType=bug.Operation EdgeType=models.OperationEdge ConnectionType=models.OperationConnection"
-//go:generate genny -in=connection_template.go -out=gen_comment.go gen "Name=Comment NodeType=bug.Comment EdgeType=models.CommentEdge ConnectionType=models.CommentConnection"
-//go:generate genny -in=connection_template.go -out=gen_timeline.go gen "Name=TimelineItem NodeType=bug.TimelineItem EdgeType=models.TimelineItemEdge ConnectionType=models.TimelineItemConnection"
-//go:generate genny -in=connection_template.go -out=gen_label.go gen "Name=Label NodeType=bug.Label EdgeType=models.LabelEdge ConnectionType=models.LabelConnection"
-
-// Package connections implement a generic GraphQL relay connection
-package connections
-
-import (
- "encoding/base64"
- "fmt"
- "strconv"
- "strings"
-)
-
-const cursorPrefix = "cursor:"
-
-// Edge define the contract for an edge in a relay connection
-type Edge interface {
- GetCursor() string
-}
-
-// OffsetToCursor create the cursor string from an offset
-func OffsetToCursor(offset int) string {
- str := fmt.Sprintf("%v%v", cursorPrefix, offset)
- return base64.StdEncoding.EncodeToString([]byte(str))
-}
-
-// CursorToOffset re-derives the offset from the cursor string.
-func CursorToOffset(cursor string) (int, error) {
- str := ""
- b, err := base64.StdEncoding.DecodeString(cursor)
- if err == nil {
- str = string(b)
- }
- str = strings.Replace(str, cursorPrefix, "", -1)
- offset, err := strconv.Atoi(str)
- if err != nil {
- return 0, fmt.Errorf("Invalid cursor")
- }
- return offset, nil
-}
diff --git a/graphql/connections/edges.go b/graphql/connections/edges.go
deleted file mode 100644
index 4e37fcd9..00000000
--- a/graphql/connections/edges.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package connections
-
-import "github.com/MichaelMure/git-bug/entity"
-
-// LazyBugEdge is a special relay edge used to implement a lazy loading connection
-type LazyBugEdge struct {
- Id entity.Id
- Cursor string
-}
-
-// GetCursor return the cursor of a LazyBugEdge
-func (lbe LazyBugEdge) GetCursor() string {
- return lbe.Cursor
-}
-
-// LazyIdentityEdge is a special relay edge used to implement a lazy loading connection
-type LazyIdentityEdge struct {
- Id entity.Id
- Cursor string
-}
-
-// GetCursor return the cursor of a LazyIdentityEdge
-func (lbe LazyIdentityEdge) GetCursor() string {
- return lbe.Cursor
-}
diff --git a/graphql/connections/gen_comment.go b/graphql/connections/gen_comment.go
deleted file mode 100644
index 9f96f2bb..00000000
--- a/graphql/connections/gen_comment.go
+++ /dev/null
@@ -1,113 +0,0 @@
-// This file was automatically generated by genny.
-// Any changes will be lost if this file is regenerated.
-// see https://github.com/cheekybits/genny
-
-package connections
-
-import (
- "fmt"
-
- "github.com/MichaelMure/git-bug/bug"
- "github.com/MichaelMure/git-bug/graphql/models"
-)
-
-// BugCommentEdgeMaker define a function that take a bug.Comment and an offset and
-// create an Edge.
-type CommentEdgeMaker func(value bug.Comment, offset int) Edge
-
-// CommentConMaker define a function that create a models.CommentConnection
-type CommentConMaker func(
- edges []*models.CommentEdge,
- nodes []bug.Comment,
- info *models.PageInfo,
- totalCount int) (*models.CommentConnection, error)
-
-// CommentCon will paginate a source according to the input of a relay connection
-func CommentCon(source []bug.Comment, edgeMaker CommentEdgeMaker, conMaker CommentConMaker, input models.ConnectionInput) (*models.CommentConnection, error) {
- var nodes []bug.Comment
- var edges []*models.CommentEdge
- var cursors []string
- var pageInfo = &models.PageInfo{}
- var totalCount = len(source)
-
- emptyCon, _ := conMaker(edges, nodes, pageInfo, 0)
-
- offset := 0
-
- if input.After != nil {
- for i, value := range source {
- edge := edgeMaker(value, i)
- if edge.GetCursor() == *input.After {
- // remove all previous element including the "after" one
- source = source[i+1:]
- offset = i + 1
- pageInfo.HasPreviousPage = true
- break
- }
- }
- }
-
- if input.Before != nil {
- for i, value := range source {
- edge := edgeMaker(value, i+offset)
-
- if edge.GetCursor() == *input.Before {
- // remove all after element including the "before" one
- pageInfo.HasNextPage = true
- break
- }
-
- e := edge.(models.CommentEdge)
- edges = append(edges, &e)
- cursors = append(cursors, edge.GetCursor())
- nodes = append(nodes, value)
- }
- } else {
- edges = make([]*models.CommentEdge, len(source))
- cursors = make([]string, len(source))
- nodes = source
-
- for i, value := range source {
- edge := edgeMaker(value, i+offset)
- e := edge.(models.CommentEdge)
- edges[i] = &e
- cursors[i] = edge.GetCursor()
- }
- }
-
- if input.First != nil {
- if *input.First < 0 {
- return emptyCon, fmt.Errorf("first less than zero")
- }
-
- if len(edges) > *input.First {
- // Slice result to be of length first by removing edges from the end
- edges = edges[:*input.First]
- cursors = cursors[:*input.First]
- nodes = nodes[:*input.First]
- pageInfo.HasNextPage = true
- }
- }
-
- if input.Last != nil {
- if *input.Last < 0 {
- return emptyCon, fmt.Errorf("last less than zero")
- }
-
- if len(edges) > *input.Last {
- // Slice result to be of length last by removing edges from the start
- edges = edges[len(edges)-*input.Last:]
- cursors = cursors[len(cursors)-*input.Last:]
- nodes = nodes[len(nodes)-*input.Last:]
- pageInfo.HasPreviousPage = true
- }
- }
-
- // Fill up pageInfo cursors
- if len(cursors) > 0 {
- pageInfo.StartCursor = cursors[0]
- pageInfo.EndCursor = cursors[len(cursors)-1]
- }
-
- return conMaker(edges, nodes, pageInfo, totalCount)
-}
diff --git a/graphql/connections/gen_identity.go b/graphql/connections/gen_identity.go
deleted file mode 100644
index 061e8936..00000000
--- a/graphql/connections/gen_identity.go
+++ /dev/null
@@ -1,112 +0,0 @@
-// This file was automatically generated by genny.
-// Any changes will be lost if this file is regenerated.
-// see https://github.com/cheekybits/genny
-
-package connections
-
-import (
- "fmt"
-
- "github.com/MichaelMure/git-bug/graphql/models"
-)
-
-// ModelsIdentityWrapperEdgeMaker define a function that take a models.IdentityWrapper and an offset and
-// create an Edge.
-type IdentityEdgeMaker func(value models.IdentityWrapper, offset int) Edge
-
-// IdentityConMaker define a function that create a models.IdentityConnection
-type IdentityConMaker func(
- edges []*models.IdentityEdge,
- nodes []models.IdentityWrapper,
- info *models.PageInfo,
- totalCount int) (*models.IdentityConnection, error)
-
-// IdentityCon will paginate a source according to the input of a relay connection
-func IdentityCon(source []models.IdentityWrapper, edgeMaker IdentityEdgeMaker, conMaker IdentityConMaker, input models.ConnectionInput) (*models.IdentityConnection, error) {
- var nodes []models.IdentityWrapper
- var edges []*models.IdentityEdge
- var cursors []string
- var pageInfo = &models.PageInfo{}
- var totalCount = len(source)
-
- emptyCon, _ := conMaker(edges, nodes, pageInfo, 0)
-
- offset := 0
-
- if input.After != nil {
- for i, value := range source {
- edge := edgeMaker(value, i)
- if edge.GetCursor() == *input.After {
- // remove all previous element including the "after" one
- source = source[i+1:]
- offset = i + 1
- pageInfo.HasPreviousPage = true
- break
- }
- }
- }
-
- if input.Before != nil {
- for i, value := range source {
- edge := edgeMaker(value, i+offset)
-
- if edge.GetCursor() == *input.Before {
- // remove all after element including the "before" one
- pageInfo.HasNextPage = true
- break
- }
-
- e := edge.(models.IdentityEdge)
- edges = append(edges, &e)
- cursors = append(cursors, edge.GetCursor())
- nodes = append(nodes, value)
- }
- } else {
- edges = make([]*models.IdentityEdge, len(source))
- cursors = make([]string, len(source))
- nodes = source
-
- for i, value := range source {
- edge := edgeMaker(value, i+offset)
- e := edge.(models.IdentityEdge)
- edges[i] = &e
- cursors[i] = edge.GetCursor()
- }
- }
-
- if input.First != nil {
- if *input.First < 0 {
- return emptyCon, fmt.Errorf("first less than zero")
- }
-
- if len(edges) > *input.First {
- // Slice result to be of length first by removing edges from the end
- edges = edges[:*input.First]
- cursors = cursors[:*input.First]
- nodes = nodes[:*input.First]
- pageInfo.HasNextPage = true
- }
- }
-
- if input.Last != nil {
- if *input.Last < 0 {
- return emptyCon, fmt.Errorf("last less than zero")
- }
-
- if len(edges) > *input.Last {
- // Slice result to be of length last by removing edges from the start
- edges = edges[len(edges)-*input.Last:]
- cursors = cursors[len(cursors)-*input.Last:]
- nodes = nodes[len(nodes)-*input.Last:]
- pageInfo.HasPreviousPage = true
- }
- }
-
- // Fill up pageInfo cursors
- if len(cursors) > 0 {
- pageInfo.StartCursor = cursors[0]
- pageInfo.EndCursor = cursors[len(cursors)-1]
- }
-
- return conMaker(edges, nodes, pageInfo, totalCount)
-}
diff --git a/graphql/connections/gen_label.go b/graphql/connections/gen_label.go
deleted file mode 100644
index 7f1b2fc9..00000000
--- a/graphql/connections/gen_label.go
+++ /dev/null
@@ -1,113 +0,0 @@
-// This file was automatically generated by genny.
-// Any changes will be lost if this file is regenerated.
-// see https://github.com/cheekybits/genny
-
-package connections
-
-import (
- "fmt"
-
- "github.com/MichaelMure/git-bug/bug"
- "github.com/MichaelMure/git-bug/graphql/models"
-)
-
-// BugLabelEdgeMaker define a function that take a bug.Label and an offset and
-// create an Edge.
-type LabelEdgeMaker func(value bug.Label, offset int) Edge
-
-// LabelConMaker define a function that create a models.LabelConnection
-type LabelConMaker func(
- edges []*models.LabelEdge,
- nodes []bug.Label,
- info *models.PageInfo,
- totalCount int) (*models.LabelConnection, error)
-
-// LabelCon will paginate a source according to the input of a relay connection
-func LabelCon(source []bug.Label, edgeMaker LabelEdgeMaker, conMaker LabelConMaker, input models.ConnectionInput) (*models.LabelConnection, error) {
- var nodes []bug.Label
- var edges []*models.LabelEdge
- var cursors []string
- var pageInfo = &models.PageInfo{}
- var totalCount = len(source)
-
- emptyCon, _ := conMaker(edges, nodes, pageInfo, 0)
-
- offset := 0
-
- if input.After != nil {
- for i, value := range source {
- edge := edgeMaker(value, i)
- if edge.GetCursor() == *input.After {
- // remove all previous element including the "after" one
- source = source[i+1:]
- offset = i + 1
- pageInfo.HasPreviousPage = true
- break
- }
- }
- }
-
- if input.Before != nil {
- for i, value := range source {
- edge := edgeMaker(value, i+offset)
-
- if edge.GetCursor() == *input.Before {
- // remove all after element including the "before" one
- pageInfo.HasNextPage = true
- break
- }
-
- e := edge.(models.LabelEdge)
- edges = append(edges, &e)
- cursors = append(cursors, edge.GetCursor())
- nodes = append(nodes, value)
- }
- } else {
- edges = make([]*models.LabelEdge, len(source))
- cursors = make([]string, len(source))
- nodes = source
-
- for i, value := range source {
- edge := edgeMaker(value, i+offset)
- e := edge.(models.LabelEdge)
- edges[i] = &e
- cursors[i] = edge.GetCursor()
- }
- }
-
- if input.First != nil {
- if *input.First < 0 {
- return emptyCon, fmt.Errorf("first less than zero")
- }
-
- if len(edges) > *input.First {
- // Slice result to be of length first by removing edges from the end
- edges = edges[:*input.First]
- cursors = cursors[:*input.First]
- nodes = nodes[:*input.First]
- pageInfo.HasNextPage = true
- }
- }
-
- if input.Last != nil {
- if *input.Last < 0 {
- return emptyCon, fmt.Errorf("last less than zero")
- }
-
- if len(edges) > *input.Last {
- // Slice result to be of length last by removing edges from the start
- edges = edges[len(edges)-*input.Last:]
- cursors = cursors[len(cursors)-*input.Last:]
- nodes = nodes[len(nodes)-*input.Last:]
- pageInfo.HasPreviousPage = true
- }
- }
-
- // Fill up pageInfo cursors
- if len(cursors) > 0 {
- pageInfo.StartCursor = cursors[0]
- pageInfo.EndCursor = cursors[len(cursors)-1]
- }
-
- return conMaker(edges, nodes, pageInfo, totalCount)
-}
diff --git a/graphql/connections/gen_lazy_bug.go b/graphql/connections/gen_lazy_bug.go
deleted file mode 100644
index 9638e86b..00000000
--- a/graphql/connections/gen_lazy_bug.go
+++ /dev/null
@@ -1,113 +0,0 @@
-// This file was automatically generated by genny.
-// Any changes will be lost if this file is regenerated.
-// see https://github.com/cheekybits/genny
-
-package connections
-
-import (
- "fmt"
-
- "github.com/MichaelMure/git-bug/entity"
- "github.com/MichaelMure/git-bug/graphql/models"
-)
-
-// EntityIdEdgeMaker define a function that take a entity.Id and an offset and
-// create an Edge.
-type LazyBugEdgeMaker func(value entity.Id, offset int) Edge
-
-// LazyBugConMaker define a function that create a models.BugConnection
-type LazyBugConMaker func(
- edges []*LazyBugEdge,
- nodes []entity.Id,
- info *models.PageInfo,
- totalCount int) (*models.BugConnection, error)
-
-// LazyBugCon will paginate a source according to the input of a relay connection
-func LazyBugCon(source []entity.Id, edgeMaker LazyBugEdgeMaker, conMaker LazyBugConMaker, input models.ConnectionInput) (*models.BugConnection, error) {
- var nodes []entity.Id
- var edges []*LazyBugEdge
- var cursors []string
- var pageInfo = &models.PageInfo{}
- var totalCount = len(source)
-
- emptyCon, _ := conMaker(edges, nodes, pageInfo, 0)
-
- offset := 0
-
- if input.After != nil {
- for i, value := range source {
- edge := edgeMaker(value, i)
- if edge.GetCursor() == *input.After {
- // remove all previous element including the "after" one
- source = source[i+1:]
- offset = i + 1
- pageInfo.HasPreviousPage = true
- break
- }
- }
- }
-
- if input.Before != nil {
- for i, value := range source {
- edge := edgeMaker(value, i+offset)
-
- if edge.GetCursor() == *input.Before {
- // remove all after element including the "before" one
- pageInfo.HasNextPage = true
- break
- }
-
- e := edge.(LazyBugEdge)
- edges = append(edges, &e)
- cursors = append(cursors, edge.GetCursor())
- nodes = append(nodes, value)
- }
- } else {
- edges = make([]*LazyBugEdge, len(source))
- cursors = make([]string, len(source))
- nodes = source
-
- for i, value := range source {
- edge := edgeMaker(value, i+offset)
- e := edge.(LazyBugEdge)
- edges[i] = &e
- cursors[i] = edge.GetCursor()
- }
- }
-
- if input.First != nil {
- if *input.First < 0 {
- return emptyCon, fmt.Errorf("first less than zero")
- }
-
- if len(edges) > *input.First {
- // Slice result to be of length first by removing edges from the end
- edges = edges[:*input.First]
- cursors = cursors[:*input.First]
- nodes = nodes[:*input.First]
- pageInfo.HasNextPage = true
- }
- }
-
- if input.Last != nil {
- if *input.Last < 0 {
- return emptyCon, fmt.Errorf("last less than zero")
- }
-
- if len(edges) > *input.Last {
- // Slice result to be of length last by removing edges from the start
- edges = edges[len(edges)-*input.Last:]
- cursors = cursors[len(cursors)-*input.Last:]
- nodes = nodes[len(nodes)-*input.Last:]
- pageInfo.HasPreviousPage = true
- }
- }
-
- // Fill up pageInfo cursors
- if len(cursors) > 0 {
- pageInfo.StartCursor = cursors[0]
- pageInfo.EndCursor = cursors[len(cursors)-1]
- }
-
- return conMaker(edges, nodes, pageInfo, totalCount)
-}
diff --git a/graphql/connections/gen_lazy_identity.go b/graphql/connections/gen_lazy_identity.go
deleted file mode 100644
index 932d802c..00000000
--- a/graphql/connections/gen_lazy_identity.go
+++ /dev/null
@@ -1,113 +0,0 @@
-// This file was automatically generated by genny.
-// Any changes will be lost if this file is regenerated.
-// see https://github.com/cheekybits/genny
-
-package connections
-
-import (
- "fmt"
-
- "github.com/MichaelMure/git-bug/entity"
- "github.com/MichaelMure/git-bug/graphql/models"
-)
-
-// EntityIdEdgeMaker define a function that take a entity.Id and an offset and
-// create an Edge.
-type LazyIdentityEdgeMaker func(value entity.Id, offset int) Edge
-
-// LazyIdentityConMaker define a function that create a models.IdentityConnection
-type LazyIdentityConMaker func(
- edges []*LazyIdentityEdge,
- nodes []entity.Id,
- info *models.PageInfo,
- totalCount int) (*models.IdentityConnection, error)
-
-// LazyIdentityCon will paginate a source according to the input of a relay connection
-func LazyIdentityCon(source []entity.Id, edgeMaker LazyIdentityEdgeMaker, conMaker LazyIdentityConMaker, input models.ConnectionInput) (*models.IdentityConnection, error) {
- var nodes []entity.Id
- var edges []*LazyIdentityEdge
- var cursors []string
- var pageInfo = &models.PageInfo{}
- var totalCount = len(source)
-
- emptyCon, _ := conMaker(edges, nodes, pageInfo, 0)
-
- offset := 0
-
- if input.After != nil {
- for i, value := range source {
- edge := edgeMaker(value, i)
- if edge.GetCursor() == *input.After {
- // remove all previous element including the "after" one
- source = source[i+1:]
- offset = i + 1
- pageInfo.HasPreviousPage = true
- break
- }
- }
- }
-
- if input.Before != nil {
- for i, value := range source {
- edge := edgeMaker(value, i+offset)
-
- if edge.GetCursor() == *input.Before {
- // remove all after element including the "before" one
- pageInfo.HasNextPage = true
- break
- }
-
- e := edge.(LazyIdentityEdge)
- edges = append(edges, &e)
- cursors = append(cursors, edge.GetCursor())
- nodes = append(nodes, value)
- }
- } else {
- edges = make([]*LazyIdentityEdge, len(source))
- cursors = make([]string, len(source))
- nodes = source
-
- for i, value := range source {
- edge := edgeMaker(value, i+offset)
- e := edge.(LazyIdentityEdge)
- edges[i] = &e
- cursors[i] = edge.GetCursor()
- }
- }
-
- if input.First != nil {
- if *input.First < 0 {
- return emptyCon, fmt.Errorf("first less than zero")
- }
-
- if len(edges) > *input.First {
- // Slice result to be of length first by removing edges from the end
- edges = edges[:*input.First]
- cursors = cursors[:*input.First]
- nodes = nodes[:*input.First]
- pageInfo.HasNextPage = true
- }
- }
-
- if input.Last != nil {
- if *input.Last < 0 {
- return emptyCon, fmt.Errorf("last less than zero")
- }
-
- if len(edges) > *input.Last {
- // Slice result to be of length last by removing edges from the start
- edges = edges[len(edges)-*input.Last:]
- cursors = cursors[len(cursors)-*input.Last:]
- nodes = nodes[len(nodes)-*input.Last:]
- pageInfo.HasPreviousPage = true
- }
- }
-
- // Fill up pageInfo cursors
- if len(cursors) > 0 {
- pageInfo.StartCursor = cursors[0]
- pageInfo.EndCursor = cursors[len(cursors)-1]
- }
-
- return conMaker(edges, nodes, pageInfo, totalCount)
-}
diff --git a/graphql/connections/gen_operation.go b/graphql/connections/gen_operation.go
deleted file mode 100644
index 0f40e2c4..00000000
--- a/graphql/connections/gen_operation.go
+++ /dev/null
@@ -1,113 +0,0 @@
-// This file was automatically generated by genny.
-// Any changes will be lost if this file is regenerated.
-// see https://github.com/cheekybits/genny
-
-package connections
-
-import (
- "fmt"
-
- "github.com/MichaelMure/git-bug/bug"
- "github.com/MichaelMure/git-bug/graphql/models"
-)
-
-// BugOperationEdgeMaker define a function that take a bug.Operation and an offset and
-// create an Edge.
-type OperationEdgeMaker func(value bug.Operation, offset int) Edge
-
-// OperationConMaker define a function that create a models.OperationConnection
-type OperationConMaker func(
- edges []*models.OperationEdge,
- nodes []bug.Operation,
- info *models.PageInfo,
- totalCount int) (*models.OperationConnection, error)
-
-// OperationCon will paginate a source according to the input of a relay connection
-func OperationCon(source []bug.Operation, edgeMaker OperationEdgeMaker, conMaker OperationConMaker, input models.ConnectionInput) (*models.OperationConnection, error) {
- var nodes []bug.Operation
- var edges []*models.OperationEdge
- var cursors []string
- var pageInfo = &models.PageInfo{}
- var totalCount = len(source)
-
- emptyCon, _ := conMaker(edges, nodes, pageInfo, 0)
-
- offset := 0
-
- if input.After != nil {
- for i, value := range source {
- edge := edgeMaker(value, i)
- if edge.GetCursor() == *input.After {
- // remove all previous element including the "after" one
- source = source[i+1:]
- offset = i + 1
- pageInfo.HasPreviousPage = true
- break
- }
- }
- }
-
- if input.Before != nil {
- for i, value := range source {
- edge := edgeMaker(value, i+offset)
-
- if edge.GetCursor() == *input.Before {
- // remove all after element including the "before" one
- pageInfo.HasNextPage = true
- break
- }
-
- e := edge.(models.OperationEdge)
- edges = append(edges, &e)
- cursors = append(cursors, edge.GetCursor())
- nodes = append(nodes, value)
- }
- } else {
- edges = make([]*models.OperationEdge, len(source))
- cursors = make([]string, len(source))
- nodes = source
-
- for i, value := range source {
- edge := edgeMaker(value, i+offset)
- e := edge.(models.OperationEdge)
- edges[i] = &e
- cursors[i] = edge.GetCursor()
- }
- }
-
- if input.First != nil {
- if *input.First < 0 {
- return emptyCon, fmt.Errorf("first less than zero")
- }
-
- if len(edges) > *input.First {
- // Slice result to be of length first by removing edges from the end
- edges = edges[:*input.First]
- cursors = cursors[:*input.First]
- nodes = nodes[:*input.First]
- pageInfo.HasNextPage = true
- }
- }
-
- if input.Last != nil {
- if *input.Last < 0 {
- return emptyCon, fmt.Errorf("last less than zero")
- }
-
- if len(edges) > *input.Last {
- // Slice result to be of length last by removing edges from the start
- edges = edges[len(edges)-*input.Last:]
- cursors = cursors[len(cursors)-*input.Last:]
- nodes = nodes[len(nodes)-*input.Last:]
- pageInfo.HasPreviousPage = true
- }
- }
-
- // Fill up pageInfo cursors
- if len(cursors) > 0 {
- pageInfo.StartCursor = cursors[0]
- pageInfo.EndCursor = cursors[len(cursors)-1]
- }
-
- return conMaker(edges, nodes, pageInfo, totalCount)
-}
diff --git a/graphql/connections/gen_timeline.go b/graphql/connections/gen_timeline.go
deleted file mode 100644
index 01dac96b..00000000
--- a/graphql/connections/gen_timeline.go
+++ /dev/null
@@ -1,113 +0,0 @@
-// This file was automatically generated by genny.
-// Any changes will be lost if this file is regenerated.
-// see https://github.com/cheekybits/genny
-
-package connections
-
-import (
- "fmt"
-
- "github.com/MichaelMure/git-bug/bug"
- "github.com/MichaelMure/git-bug/graphql/models"
-)
-
-// BugTimelineItemEdgeMaker define a function that take a bug.TimelineItem and an offset and
-// create an Edge.
-type TimelineItemEdgeMaker func(value bug.TimelineItem, offset int) Edge
-
-// TimelineItemConMaker define a function that create a models.TimelineItemConnection
-type TimelineItemConMaker func(
- edges []*models.TimelineItemEdge,
- nodes []bug.TimelineItem,
- info *models.PageInfo,
- totalCount int) (*models.TimelineItemConnection, error)
-
-// TimelineItemCon will paginate a source according to the input of a relay connection
-func TimelineItemCon(source []bug.TimelineItem, edgeMaker TimelineItemEdgeMaker, conMaker TimelineItemConMaker, input models.ConnectionInput) (*models.TimelineItemConnection, error) {
- var nodes []bug.TimelineItem
- var edges []*models.TimelineItemEdge
- var cursors []string
- var pageInfo = &models.PageInfo{}
- var totalCount = len(source)
-
- emptyCon, _ := conMaker(edges, nodes, pageInfo, 0)
-
- offset := 0
-
- if input.After != nil {
- for i, value := range source {
- edge := edgeMaker(value, i)
- if edge.GetCursor() == *input.After {
- // remove all previous element including the "after" one
- source = source[i+1:]
- offset = i + 1
- pageInfo.HasPreviousPage = true
- break
- }
- }
- }
-
- if input.Before != nil {
- for i, value := range source {
- edge := edgeMaker(value, i+offset)
-
- if edge.GetCursor() == *input.Before {
- // remove all after element including the "before" one
- pageInfo.HasNextPage = true
- break
- }
-
- e := edge.(models.TimelineItemEdge)
- edges = append(edges, &e)
- cursors = append(cursors, edge.GetCursor())
- nodes = append(nodes, value)
- }
- } else {
- edges = make([]*models.TimelineItemEdge, len(source))
- cursors = make([]string, len(source))
- nodes = source
-
- for i, value := range source {
- edge := edgeMaker(value, i+offset)
- e := edge.(models.TimelineItemEdge)
- edges[i] = &e
- cursors[i] = edge.GetCursor()
- }
- }
-
- if input.First != nil {
- if *input.First < 0 {
- return emptyCon, fmt.Errorf("first less than zero")
- }
-
- if len(edges) > *input.First {
- // Slice result to be of length first by removing edges from the end
- edges = edges[:*input.First]
- cursors = cursors[:*input.First]
- nodes = nodes[:*input.First]
- pageInfo.HasNextPage = true
- }
- }
-
- if input.Last != nil {
- if *input.Last < 0 {
- return emptyCon, fmt.Errorf("last less than zero")
- }
-
- if len(edges) > *input.Last {
- // Slice result to be of length last by removing edges from the start
- edges = edges[len(edges)-*input.Last:]
- cursors = cursors[len(cursors)-*input.Last:]
- nodes = nodes[len(nodes)-*input.Last:]
- pageInfo.HasPreviousPage = true
- }
- }
-
- // Fill up pageInfo cursors
- if len(cursors) > 0 {
- pageInfo.StartCursor = cursors[0]
- pageInfo.EndCursor = cursors[len(cursors)-1]
- }
-
- return conMaker(edges, nodes, pageInfo, totalCount)
-}