aboutsummaryrefslogtreecommitdiffstats
path: root/graphql/resolvers/operations.go
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/resolvers/operations.go
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/resolvers/operations.go')
-rw-r--r--graphql/resolvers/operations.go52
1 files changed, 38 insertions, 14 deletions
diff --git a/graphql/resolvers/operations.go b/graphql/resolvers/operations.go
index ec803c1f..29110cf3 100644
--- a/graphql/resolvers/operations.go
+++ b/graphql/resolvers/operations.go
@@ -14,11 +14,15 @@ var _ graph.CreateOperationResolver = createOperationResolver{}
type createOperationResolver struct{}
-func (createOperationResolver) ID(ctx context.Context, obj *bug.CreateOperation) (string, error) {
+func (createOperationResolver) ID(_ context.Context, obj *bug.CreateOperation) (string, error) {
return obj.Id().String(), nil
}
-func (createOperationResolver) Date(ctx context.Context, obj *bug.CreateOperation) (*time.Time, error) {
+func (createOperationResolver) Author(_ context.Context, obj *bug.CreateOperation) (models.IdentityWrapper, error) {
+ return models.NewLoadedIdentity(obj.Author), nil
+}
+
+func (createOperationResolver) Date(_ context.Context, obj *bug.CreateOperation) (*time.Time, error) {
t := obj.Time()
return &t, nil
}
@@ -27,11 +31,15 @@ var _ graph.AddCommentOperationResolver = addCommentOperationResolver{}
type addCommentOperationResolver struct{}
-func (addCommentOperationResolver) ID(ctx context.Context, obj *bug.AddCommentOperation) (string, error) {
+func (addCommentOperationResolver) ID(_ context.Context, obj *bug.AddCommentOperation) (string, error) {
return obj.Id().String(), nil
}
-func (addCommentOperationResolver) Date(ctx context.Context, obj *bug.AddCommentOperation) (*time.Time, error) {
+func (addCommentOperationResolver) Author(_ context.Context, obj *bug.AddCommentOperation) (models.IdentityWrapper, error) {
+ return models.NewLoadedIdentity(obj.Author), nil
+}
+
+func (addCommentOperationResolver) Date(_ context.Context, obj *bug.AddCommentOperation) (*time.Time, error) {
t := obj.Time()
return &t, nil
}
@@ -40,15 +48,19 @@ var _ graph.EditCommentOperationResolver = editCommentOperationResolver{}
type editCommentOperationResolver struct{}
-func (editCommentOperationResolver) ID(ctx context.Context, obj *bug.EditCommentOperation) (string, error) {
+func (editCommentOperationResolver) ID(_ context.Context, obj *bug.EditCommentOperation) (string, error) {
return obj.Id().String(), nil
}
-func (editCommentOperationResolver) Target(ctx context.Context, obj *bug.EditCommentOperation) (string, error) {
+func (editCommentOperationResolver) Target(_ context.Context, obj *bug.EditCommentOperation) (string, error) {
return obj.Target.String(), nil
}
-func (editCommentOperationResolver) Date(ctx context.Context, obj *bug.EditCommentOperation) (*time.Time, error) {
+func (editCommentOperationResolver) Author(_ context.Context, obj *bug.EditCommentOperation) (models.IdentityWrapper, error) {
+ return models.NewLoadedIdentity(obj.Author), nil
+}
+
+func (editCommentOperationResolver) Date(_ context.Context, obj *bug.EditCommentOperation) (*time.Time, error) {
t := obj.Time()
return &t, nil
}
@@ -57,11 +69,15 @@ var _ graph.LabelChangeOperationResolver = labelChangeOperationResolver{}
type labelChangeOperationResolver struct{}
-func (labelChangeOperationResolver) ID(ctx context.Context, obj *bug.LabelChangeOperation) (string, error) {
+func (labelChangeOperationResolver) ID(_ context.Context, obj *bug.LabelChangeOperation) (string, error) {
return obj.Id().String(), nil
}
-func (labelChangeOperationResolver) Date(ctx context.Context, obj *bug.LabelChangeOperation) (*time.Time, error) {
+func (labelChangeOperationResolver) Author(_ context.Context, obj *bug.LabelChangeOperation) (models.IdentityWrapper, error) {
+ return models.NewLoadedIdentity(obj.Author), nil
+}
+
+func (labelChangeOperationResolver) Date(_ context.Context, obj *bug.LabelChangeOperation) (*time.Time, error) {
t := obj.Time()
return &t, nil
}
@@ -70,16 +86,20 @@ var _ graph.SetStatusOperationResolver = setStatusOperationResolver{}
type setStatusOperationResolver struct{}
-func (setStatusOperationResolver) ID(ctx context.Context, obj *bug.SetStatusOperation) (string, error) {
+func (setStatusOperationResolver) ID(_ context.Context, obj *bug.SetStatusOperation) (string, error) {
return obj.Id().String(), nil
}
-func (setStatusOperationResolver) Date(ctx context.Context, obj *bug.SetStatusOperation) (*time.Time, error) {
+func (setStatusOperationResolver) Author(_ context.Context, obj *bug.SetStatusOperation) (models.IdentityWrapper, error) {
+ return models.NewLoadedIdentity(obj.Author), nil
+}
+
+func (setStatusOperationResolver) Date(_ context.Context, obj *bug.SetStatusOperation) (*time.Time, error) {
t := obj.Time()
return &t, nil
}
-func (setStatusOperationResolver) Status(ctx context.Context, obj *bug.SetStatusOperation) (models.Status, error) {
+func (setStatusOperationResolver) Status(_ context.Context, obj *bug.SetStatusOperation) (models.Status, error) {
return convertStatus(obj.Status)
}
@@ -87,11 +107,15 @@ var _ graph.SetTitleOperationResolver = setTitleOperationResolver{}
type setTitleOperationResolver struct{}
-func (setTitleOperationResolver) ID(ctx context.Context, obj *bug.SetTitleOperation) (string, error) {
+func (setTitleOperationResolver) ID(_ context.Context, obj *bug.SetTitleOperation) (string, error) {
return obj.Id().String(), nil
}
-func (setTitleOperationResolver) Date(ctx context.Context, obj *bug.SetTitleOperation) (*time.Time, error) {
+func (setTitleOperationResolver) Author(_ context.Context, obj *bug.SetTitleOperation) (models.IdentityWrapper, error) {
+ return models.NewLoadedIdentity(obj.Author), nil
+}
+
+func (setTitleOperationResolver) Date(_ context.Context, obj *bug.SetTitleOperation) (*time.Time, error) {
t := obj.Time()
return &t, nil
}