aboutsummaryrefslogtreecommitdiffstats
path: root/graphql/connections
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-02-03 21:03:48 +0100
committerMichael Muré <batolettre@gmail.com>2020-02-09 02:18:44 +0100
commit81f5c3e0af9aa4b81662e0781289189703324986 (patch)
treebe229ccfb135445bf5355b1e8506d870af5f472b /graphql/connections
parent9e1a987b4d94dc5c2115423ede5954d4faf1d342 (diff)
downloadgit-bug-81f5c3e0af9aa4b81662e0781289189703324986.tar.gz
graphql: use the cache in priority for fast browsing at < 20ms instead of seconds
Diffstat (limited to 'graphql/connections')
-rw-r--r--graphql/connections/connections.go2
-rw-r--r--graphql/connections/edges.go (renamed from graphql/connections/lazy_identity.go)11
-rw-r--r--graphql/connections/gen_identity.go11
-rw-r--r--graphql/connections/lazy_bug.go14
4 files changed, 17 insertions, 21 deletions
diff --git a/graphql/connections/connections.go b/graphql/connections/connections.go
index 82ad2514..0083f8b2 100644
--- a/graphql/connections/connections.go
+++ b/graphql/connections/connections.go
@@ -1,6 +1,6 @@
//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=identity.Interface EdgeType=models.IdentityEdge 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"
diff --git a/graphql/connections/lazy_identity.go b/graphql/connections/edges.go
index 3274dd7e..4e37fcd9 100644
--- a/graphql/connections/lazy_identity.go
+++ b/graphql/connections/edges.go
@@ -2,6 +2,17 @@ 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
diff --git a/graphql/connections/gen_identity.go b/graphql/connections/gen_identity.go
index b52b6f96..061e8936 100644
--- a/graphql/connections/gen_identity.go
+++ b/graphql/connections/gen_identity.go
@@ -8,23 +8,22 @@ import (
"fmt"
"github.com/MichaelMure/git-bug/graphql/models"
- "github.com/MichaelMure/git-bug/identity"
)
-// IdentityInterfaceEdgeMaker define a function that take a identity.Interface and an offset and
+// ModelsIdentityWrapperEdgeMaker define a function that take a models.IdentityWrapper and an offset and
// create an Edge.
-type IdentityEdgeMaker func(value identity.Interface, offset int) 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 []identity.Interface,
+ 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 []identity.Interface, edgeMaker IdentityEdgeMaker, conMaker IdentityConMaker, input models.ConnectionInput) (*models.IdentityConnection, error) {
- var nodes []identity.Interface
+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{}
diff --git a/graphql/connections/lazy_bug.go b/graphql/connections/lazy_bug.go
deleted file mode 100644
index 00692e8b..00000000
--- a/graphql/connections/lazy_bug.go
+++ /dev/null
@@ -1,14 +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
-}