mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-14 17:51:44 +03:00
Support gqlgen v0.8.3
This commit is contained in:
parent
30efc99f44
commit
6e8496f4c1
@ -29,10 +29,10 @@ type NameConMaker func(
|
||||
edges []EdgeType,
|
||||
nodes []NodeType,
|
||||
info models.PageInfo,
|
||||
totalCount int) (ConnectionType, error)
|
||||
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) {
|
||||
func NameCon(source []NodeType, edgeMaker NameEdgeMaker, conMaker NameConMaker, input models.ConnectionInput) (*ConnectionType, error) {
|
||||
var nodes []NodeType
|
||||
var edges []EdgeType
|
||||
var cursors []string
|
||||
|
@ -20,10 +20,10 @@ type CommentConMaker func(
|
||||
edges []models.CommentEdge,
|
||||
nodes []bug.Comment,
|
||||
info models.PageInfo,
|
||||
totalCount int) (models.CommentConnection, error)
|
||||
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) {
|
||||
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
|
||||
|
@ -20,10 +20,10 @@ type IdentityConMaker func(
|
||||
edges []models.IdentityEdge,
|
||||
nodes []identity.Interface,
|
||||
info models.PageInfo,
|
||||
totalCount int) (models.IdentityConnection, error)
|
||||
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) {
|
||||
func IdentityCon(source []identity.Interface, edgeMaker IdentityEdgeMaker, conMaker IdentityConMaker, input models.ConnectionInput) (*models.IdentityConnection, error) {
|
||||
var nodes []identity.Interface
|
||||
var edges []models.IdentityEdge
|
||||
var cursors []string
|
||||
|
@ -19,10 +19,10 @@ type LazyBugConMaker func(
|
||||
edges []LazyBugEdge,
|
||||
nodes []string,
|
||||
info models.PageInfo,
|
||||
totalCount int) (models.BugConnection, error)
|
||||
totalCount int) (*models.BugConnection, error)
|
||||
|
||||
// LazyBugCon will paginate a source according to the input of a relay connection
|
||||
func LazyBugCon(source []string, edgeMaker LazyBugEdgeMaker, conMaker LazyBugConMaker, input models.ConnectionInput) (models.BugConnection, error) {
|
||||
func LazyBugCon(source []string, edgeMaker LazyBugEdgeMaker, conMaker LazyBugConMaker, input models.ConnectionInput) (*models.BugConnection, error) {
|
||||
var nodes []string
|
||||
var edges []LazyBugEdge
|
||||
var cursors []string
|
||||
|
@ -19,10 +19,10 @@ type LazyIdentityConMaker func(
|
||||
edges []LazyIdentityEdge,
|
||||
nodes []string,
|
||||
info models.PageInfo,
|
||||
totalCount int) (models.IdentityConnection, error)
|
||||
totalCount int) (*models.IdentityConnection, error)
|
||||
|
||||
// LazyIdentityCon will paginate a source according to the input of a relay connection
|
||||
func LazyIdentityCon(source []string, edgeMaker LazyIdentityEdgeMaker, conMaker LazyIdentityConMaker, input models.ConnectionInput) (models.IdentityConnection, error) {
|
||||
func LazyIdentityCon(source []string, edgeMaker LazyIdentityEdgeMaker, conMaker LazyIdentityConMaker, input models.ConnectionInput) (*models.IdentityConnection, error) {
|
||||
var nodes []string
|
||||
var edges []LazyIdentityEdge
|
||||
var cursors []string
|
||||
|
@ -20,10 +20,10 @@ type OperationConMaker func(
|
||||
edges []models.OperationEdge,
|
||||
nodes []bug.Operation,
|
||||
info models.PageInfo,
|
||||
totalCount int) (models.OperationConnection, error)
|
||||
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) {
|
||||
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
|
||||
|
@ -20,10 +20,10 @@ type TimelineItemConMaker func(
|
||||
edges []models.TimelineItemEdge,
|
||||
nodes []bug.TimelineItem,
|
||||
info models.PageInfo,
|
||||
totalCount int) (models.TimelineItemConnection, error)
|
||||
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) {
|
||||
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
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -18,15 +18,20 @@ type Authored interface {
|
||||
|
||||
// The connection type for Bug.
|
||||
type BugConnection struct {
|
||||
// A list of edges.
|
||||
Edges []BugEdge `json:"edges"`
|
||||
Nodes []bug.Snapshot `json:"nodes"`
|
||||
// Information to aid in pagination.
|
||||
PageInfo PageInfo `json:"pageInfo"`
|
||||
// Identifies the total count of items in the connection.
|
||||
TotalCount int `json:"totalCount"`
|
||||
}
|
||||
|
||||
// An edge in a connection.
|
||||
type BugEdge struct {
|
||||
// A cursor for use in pagination.
|
||||
Cursor string `json:"cursor"`
|
||||
// The item at the end of the edge.
|
||||
Node bug.Snapshot `json:"node"`
|
||||
}
|
||||
|
||||
@ -70,9 +75,13 @@ type OperationEdge struct {
|
||||
|
||||
// Information about pagination in a connection.
|
||||
type PageInfo struct {
|
||||
// When paginating forwards, are there more items?
|
||||
HasNextPage bool `json:"hasNextPage"`
|
||||
// When paginating backwards, are there more items?
|
||||
HasPreviousPage bool `json:"hasPreviousPage"`
|
||||
// When paginating backwards, the cursor to continue.
|
||||
StartCursor string `json:"startCursor"`
|
||||
// When paginating forwards, the cursor to continue.
|
||||
EndCursor string `json:"endCursor"`
|
||||
}
|
||||
|
||||
@ -97,6 +106,11 @@ const (
|
||||
StatusClosed Status = "CLOSED"
|
||||
)
|
||||
|
||||
var AllStatus = []Status{
|
||||
StatusOpen,
|
||||
StatusClosed,
|
||||
}
|
||||
|
||||
func (e Status) IsValid() bool {
|
||||
switch e {
|
||||
case StatusOpen, StatusClosed:
|
||||
|
@ -19,7 +19,7 @@ func (bugResolver) Status(ctx context.Context, obj *bug.Snapshot) (models.Status
|
||||
return convertStatus(obj.Status)
|
||||
}
|
||||
|
||||
func (bugResolver) Comments(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (models.CommentConnection, error) {
|
||||
func (bugResolver) Comments(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (*models.CommentConnection, error) {
|
||||
input := models.ConnectionInput{
|
||||
Before: before,
|
||||
After: after,
|
||||
@ -34,8 +34,8 @@ func (bugResolver) Comments(ctx context.Context, obj *bug.Snapshot, after *strin
|
||||
}
|
||||
}
|
||||
|
||||
conMaker := func(edges []models.CommentEdge, nodes []bug.Comment, info models.PageInfo, totalCount int) (models.CommentConnection, error) {
|
||||
return models.CommentConnection{
|
||||
conMaker := func(edges []models.CommentEdge, nodes []bug.Comment, info models.PageInfo, totalCount int) (*models.CommentConnection, error) {
|
||||
return &models.CommentConnection{
|
||||
Edges: edges,
|
||||
Nodes: nodes,
|
||||
PageInfo: info,
|
||||
@ -46,7 +46,7 @@ func (bugResolver) Comments(ctx context.Context, obj *bug.Snapshot, after *strin
|
||||
return connections.CommentCon(obj.Comments, edger, conMaker, input)
|
||||
}
|
||||
|
||||
func (bugResolver) Operations(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (models.OperationConnection, error) {
|
||||
func (bugResolver) Operations(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (*models.OperationConnection, error) {
|
||||
input := models.ConnectionInput{
|
||||
Before: before,
|
||||
After: after,
|
||||
@ -61,8 +61,8 @@ func (bugResolver) Operations(ctx context.Context, obj *bug.Snapshot, after *str
|
||||
}
|
||||
}
|
||||
|
||||
conMaker := func(edges []models.OperationEdge, nodes []bug.Operation, info models.PageInfo, totalCount int) (models.OperationConnection, error) {
|
||||
return models.OperationConnection{
|
||||
conMaker := func(edges []models.OperationEdge, nodes []bug.Operation, info models.PageInfo, totalCount int) (*models.OperationConnection, error) {
|
||||
return &models.OperationConnection{
|
||||
Edges: edges,
|
||||
Nodes: nodes,
|
||||
PageInfo: info,
|
||||
@ -73,7 +73,7 @@ func (bugResolver) Operations(ctx context.Context, obj *bug.Snapshot, after *str
|
||||
return connections.OperationCon(obj.Operations, edger, conMaker, input)
|
||||
}
|
||||
|
||||
func (bugResolver) Timeline(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (models.TimelineItemConnection, error) {
|
||||
func (bugResolver) Timeline(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (*models.TimelineItemConnection, error) {
|
||||
input := models.ConnectionInput{
|
||||
Before: before,
|
||||
After: after,
|
||||
@ -88,8 +88,8 @@ func (bugResolver) Timeline(ctx context.Context, obj *bug.Snapshot, after *strin
|
||||
}
|
||||
}
|
||||
|
||||
conMaker := func(edges []models.TimelineItemEdge, nodes []bug.TimelineItem, info models.PageInfo, totalCount int) (models.TimelineItemConnection, error) {
|
||||
return models.TimelineItemConnection{
|
||||
conMaker := func(edges []models.TimelineItemEdge, nodes []bug.TimelineItem, info models.PageInfo, totalCount int) (*models.TimelineItemConnection, error) {
|
||||
return &models.TimelineItemConnection{
|
||||
Edges: edges,
|
||||
Nodes: nodes,
|
||||
PageInfo: info,
|
||||
@ -100,11 +100,12 @@ func (bugResolver) Timeline(ctx context.Context, obj *bug.Snapshot, after *strin
|
||||
return connections.TimelineItemCon(obj.Timeline, edger, conMaker, input)
|
||||
}
|
||||
|
||||
func (bugResolver) LastEdit(ctx context.Context, obj *bug.Snapshot) (time.Time, error) {
|
||||
return obj.LastEditTime(), nil
|
||||
func (bugResolver) LastEdit(ctx context.Context, obj *bug.Snapshot) (*time.Time, error) {
|
||||
t := obj.LastEditTime()
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
func (bugResolver) Actors(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (models.IdentityConnection, error) {
|
||||
func (bugResolver) Actors(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (*models.IdentityConnection, error) {
|
||||
input := models.ConnectionInput{
|
||||
Before: before,
|
||||
After: after,
|
||||
@ -119,8 +120,8 @@ func (bugResolver) Actors(ctx context.Context, obj *bug.Snapshot, after *string,
|
||||
}
|
||||
}
|
||||
|
||||
conMaker := func(edges []models.IdentityEdge, nodes []identity.Interface, info models.PageInfo, totalCount int) (models.IdentityConnection, error) {
|
||||
return models.IdentityConnection{
|
||||
conMaker := func(edges []models.IdentityEdge, nodes []identity.Interface, info models.PageInfo, totalCount int) (*models.IdentityConnection, error) {
|
||||
return &models.IdentityConnection{
|
||||
Edges: edges,
|
||||
Nodes: nodes,
|
||||
PageInfo: info,
|
||||
@ -131,7 +132,7 @@ func (bugResolver) Actors(ctx context.Context, obj *bug.Snapshot, after *string,
|
||||
return connections.IdentityCon(obj.Actors, edger, conMaker, input)
|
||||
}
|
||||
|
||||
func (bugResolver) Participants(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (models.IdentityConnection, error) {
|
||||
func (bugResolver) Participants(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (*models.IdentityConnection, error) {
|
||||
input := models.ConnectionInput{
|
||||
Before: before,
|
||||
After: after,
|
||||
@ -146,8 +147,8 @@ func (bugResolver) Participants(ctx context.Context, obj *bug.Snapshot, after *s
|
||||
}
|
||||
}
|
||||
|
||||
conMaker := func(edges []models.IdentityEdge, nodes []identity.Interface, info models.PageInfo, totalCount int) (models.IdentityConnection, error) {
|
||||
return models.IdentityConnection{
|
||||
conMaker := func(edges []models.IdentityEdge, nodes []identity.Interface, info models.PageInfo, totalCount int) (*models.IdentityConnection, error) {
|
||||
return &models.IdentityConnection{
|
||||
Edges: edges,
|
||||
Nodes: nodes,
|
||||
PageInfo: info,
|
||||
|
@ -23,144 +23,130 @@ func (r mutationResolver) getRepo(repoRef *string) (*cache.RepoCache, error) {
|
||||
return r.cache.DefaultRepo()
|
||||
}
|
||||
|
||||
func (r mutationResolver) NewBug(ctx context.Context, repoRef *string, title string, message string, files []git.Hash) (bug.Snapshot, error) {
|
||||
func (r mutationResolver) NewBug(ctx context.Context, repoRef *string, title string, message string, files []git.Hash) (*bug.Snapshot, error) {
|
||||
repo, err := r.getRepo(repoRef)
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
b, err := repo.NewBugWithFiles(title, message, files)
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
snap := b.Snapshot()
|
||||
|
||||
return *snap, nil
|
||||
return b.Snapshot(), nil
|
||||
}
|
||||
|
||||
func (r mutationResolver) Commit(ctx context.Context, repoRef *string, prefix string) (bug.Snapshot, error) {
|
||||
func (r mutationResolver) Commit(ctx context.Context, repoRef *string, prefix string) (*bug.Snapshot, error) {
|
||||
repo, err := r.getRepo(repoRef)
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
b, err := repo.ResolveBugPrefix(prefix)
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = b.Commit()
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
snap := b.Snapshot()
|
||||
|
||||
return *snap, nil
|
||||
return b.Snapshot(), nil
|
||||
}
|
||||
|
||||
func (r mutationResolver) AddComment(ctx context.Context, repoRef *string, prefix string, message string, files []git.Hash) (bug.Snapshot, error) {
|
||||
func (r mutationResolver) AddComment(ctx context.Context, repoRef *string, prefix string, message string, files []git.Hash) (*bug.Snapshot, error) {
|
||||
repo, err := r.getRepo(repoRef)
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
b, err := repo.ResolveBugPrefix(prefix)
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = b.AddCommentWithFiles(message, files)
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
snap := b.Snapshot()
|
||||
|
||||
return *snap, nil
|
||||
return b.Snapshot(), nil
|
||||
}
|
||||
|
||||
func (r mutationResolver) ChangeLabels(ctx context.Context, repoRef *string, prefix string, added []string, removed []string) (bug.Snapshot, error) {
|
||||
func (r mutationResolver) ChangeLabels(ctx context.Context, repoRef *string, prefix string, added []string, removed []string) (*bug.Snapshot, error) {
|
||||
repo, err := r.getRepo(repoRef)
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
b, err := repo.ResolveBugPrefix(prefix)
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, _, err = b.ChangeLabels(added, removed)
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
snap := b.Snapshot()
|
||||
|
||||
return *snap, nil
|
||||
return b.Snapshot(), nil
|
||||
}
|
||||
|
||||
func (r mutationResolver) Open(ctx context.Context, repoRef *string, prefix string) (bug.Snapshot, error) {
|
||||
func (r mutationResolver) Open(ctx context.Context, repoRef *string, prefix string) (*bug.Snapshot, error) {
|
||||
repo, err := r.getRepo(repoRef)
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
b, err := repo.ResolveBugPrefix(prefix)
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = b.Open()
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
snap := b.Snapshot()
|
||||
|
||||
return *snap, nil
|
||||
return b.Snapshot(), nil
|
||||
}
|
||||
|
||||
func (r mutationResolver) Close(ctx context.Context, repoRef *string, prefix string) (bug.Snapshot, error) {
|
||||
func (r mutationResolver) Close(ctx context.Context, repoRef *string, prefix string) (*bug.Snapshot, error) {
|
||||
repo, err := r.getRepo(repoRef)
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
b, err := repo.ResolveBugPrefix(prefix)
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = b.Close()
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
snap := b.Snapshot()
|
||||
|
||||
return *snap, nil
|
||||
return b.Snapshot(), nil
|
||||
}
|
||||
|
||||
func (r mutationResolver) SetTitle(ctx context.Context, repoRef *string, prefix string, title string) (bug.Snapshot, error) {
|
||||
func (r mutationResolver) SetTitle(ctx context.Context, repoRef *string, prefix string, title string) (*bug.Snapshot, error) {
|
||||
repo, err := r.getRepo(repoRef)
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
b, err := repo.ResolveBugPrefix(prefix)
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = b.SetTitle(title)
|
||||
if err != nil {
|
||||
return bug.Snapshot{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
snap := b.Snapshot()
|
||||
|
||||
return *snap, nil
|
||||
return b.Snapshot(), nil
|
||||
}
|
||||
|
@ -11,32 +11,37 @@ import (
|
||||
|
||||
type createOperationResolver struct{}
|
||||
|
||||
func (createOperationResolver) Date(ctx context.Context, obj *bug.CreateOperation) (time.Time, error) {
|
||||
return obj.Time(), nil
|
||||
func (createOperationResolver) Date(ctx context.Context, obj *bug.CreateOperation) (*time.Time, error) {
|
||||
t := obj.Time()
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
type addCommentOperationResolver struct{}
|
||||
|
||||
func (addCommentOperationResolver) Date(ctx context.Context, obj *bug.AddCommentOperation) (time.Time, error) {
|
||||
return obj.Time(), nil
|
||||
func (addCommentOperationResolver) Date(ctx context.Context, obj *bug.AddCommentOperation) (*time.Time, error) {
|
||||
t := obj.Time()
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
type editCommentOperationResolver struct{}
|
||||
|
||||
func (editCommentOperationResolver) Date(ctx context.Context, obj *bug.EditCommentOperation) (time.Time, error) {
|
||||
return obj.Time(), nil
|
||||
func (editCommentOperationResolver) Date(ctx context.Context, obj *bug.EditCommentOperation) (*time.Time, error) {
|
||||
t := obj.Time()
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
type labelChangeOperation struct{}
|
||||
|
||||
func (labelChangeOperation) Date(ctx context.Context, obj *bug.LabelChangeOperation) (time.Time, error) {
|
||||
return obj.Time(), nil
|
||||
func (labelChangeOperation) Date(ctx context.Context, obj *bug.LabelChangeOperation) (*time.Time, error) {
|
||||
t := obj.Time()
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
type setStatusOperationResolver struct{}
|
||||
|
||||
func (setStatusOperationResolver) Date(ctx context.Context, obj *bug.SetStatusOperation) (time.Time, error) {
|
||||
return obj.Time(), nil
|
||||
func (setStatusOperationResolver) Date(ctx 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) {
|
||||
@ -45,8 +50,9 @@ func (setStatusOperationResolver) Status(ctx context.Context, obj *bug.SetStatus
|
||||
|
||||
type setTitleOperationResolver struct{}
|
||||
|
||||
func (setTitleOperationResolver) Date(ctx context.Context, obj *bug.SetTitleOperation) (time.Time, error) {
|
||||
return obj.Time(), nil
|
||||
func (setTitleOperationResolver) Date(ctx context.Context, obj *bug.SetTitleOperation) (*time.Time, error) {
|
||||
t := obj.Time()
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
func convertStatus(status bug.Status) (models.Status, error) {
|
||||
|
@ -15,7 +15,7 @@ var _ graph.RepositoryResolver = &repoResolver{}
|
||||
|
||||
type repoResolver struct{}
|
||||
|
||||
func (repoResolver) AllBugs(ctx context.Context, obj *models.Repository, after *string, before *string, first *int, last *int, queryStr *string) (models.BugConnection, error) {
|
||||
func (repoResolver) AllBugs(ctx context.Context, obj *models.Repository, after *string, before *string, first *int, last *int, queryStr *string) (*models.BugConnection, error) {
|
||||
input := models.ConnectionInput{
|
||||
Before: before,
|
||||
After: after,
|
||||
@ -27,7 +27,7 @@ func (repoResolver) AllBugs(ctx context.Context, obj *models.Repository, after *
|
||||
if queryStr != nil {
|
||||
query2, err := cache.ParseQuery(*queryStr)
|
||||
if err != nil {
|
||||
return models.BugConnection{}, err
|
||||
return nil, err
|
||||
}
|
||||
query = query2
|
||||
} else {
|
||||
@ -46,7 +46,7 @@ func (repoResolver) AllBugs(ctx context.Context, obj *models.Repository, after *
|
||||
}
|
||||
|
||||
// The conMaker will finally load and compile bugs from git to replace the selected edges
|
||||
conMaker := func(lazyBugEdges []connections.LazyBugEdge, lazyNode []string, info models.PageInfo, totalCount int) (models.BugConnection, error) {
|
||||
conMaker := func(lazyBugEdges []connections.LazyBugEdge, lazyNode []string, info models.PageInfo, totalCount int) (*models.BugConnection, error) {
|
||||
edges := make([]models.BugEdge, len(lazyBugEdges))
|
||||
nodes := make([]bug.Snapshot, len(lazyBugEdges))
|
||||
|
||||
@ -54,7 +54,7 @@ func (repoResolver) AllBugs(ctx context.Context, obj *models.Repository, after *
|
||||
b, err := obj.Repo.ResolveBug(lazyBugEdge.Id)
|
||||
|
||||
if err != nil {
|
||||
return models.BugConnection{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
snap := b.Snapshot()
|
||||
@ -66,7 +66,7 @@ func (repoResolver) AllBugs(ctx context.Context, obj *models.Repository, after *
|
||||
nodes[i] = *snap
|
||||
}
|
||||
|
||||
return models.BugConnection{
|
||||
return &models.BugConnection{
|
||||
Edges: edges,
|
||||
Nodes: nodes,
|
||||
PageInfo: info,
|
||||
@ -87,7 +87,7 @@ func (repoResolver) Bug(ctx context.Context, obj *models.Repository, prefix stri
|
||||
return b.Snapshot(), nil
|
||||
}
|
||||
|
||||
func (repoResolver) AllIdentities(ctx context.Context, obj *models.Repository, after *string, before *string, first *int, last *int) (models.IdentityConnection, error) {
|
||||
func (repoResolver) AllIdentities(ctx context.Context, obj *models.Repository, after *string, before *string, first *int, last *int) (*models.IdentityConnection, error) {
|
||||
input := models.ConnectionInput{
|
||||
Before: before,
|
||||
After: after,
|
||||
@ -107,7 +107,7 @@ func (repoResolver) AllIdentities(ctx context.Context, obj *models.Repository, a
|
||||
}
|
||||
|
||||
// The conMaker will finally load and compile identities from git to replace the selected edges
|
||||
conMaker := func(lazyIdentityEdges []connections.LazyIdentityEdge, lazyNode []string, info models.PageInfo, totalCount int) (models.IdentityConnection, error) {
|
||||
conMaker := func(lazyIdentityEdges []connections.LazyIdentityEdge, lazyNode []string, info models.PageInfo, totalCount int) (*models.IdentityConnection, error) {
|
||||
edges := make([]models.IdentityEdge, len(lazyIdentityEdges))
|
||||
nodes := make([]identity.Interface, len(lazyIdentityEdges))
|
||||
|
||||
@ -115,7 +115,7 @@ func (repoResolver) AllIdentities(ctx context.Context, obj *models.Repository, a
|
||||
i, err := obj.Repo.ResolveIdentity(lazyIdentityEdge.Id)
|
||||
|
||||
if err != nil {
|
||||
return models.IdentityConnection{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ii := identity.Interface(i.Identity)
|
||||
@ -127,7 +127,7 @@ func (repoResolver) AllIdentities(ctx context.Context, obj *models.Repository, a
|
||||
nodes[k] = ii
|
||||
}
|
||||
|
||||
return models.IdentityConnection{
|
||||
return &models.IdentityConnection{
|
||||
Edges: edges,
|
||||
Nodes: nodes,
|
||||
PageInfo: info,
|
||||
@ -138,26 +138,22 @@ func (repoResolver) AllIdentities(ctx context.Context, obj *models.Repository, a
|
||||
return connections.LazyIdentityCon(source, edger, conMaker, input)
|
||||
}
|
||||
|
||||
func (repoResolver) Identity(ctx context.Context, obj *models.Repository, prefix string) (*identity.Interface, error) {
|
||||
func (repoResolver) Identity(ctx context.Context, obj *models.Repository, prefix string) (identity.Interface, error) {
|
||||
i, err := obj.Repo.ResolveIdentityPrefix(prefix)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ii := identity.Interface(i.Identity)
|
||||
|
||||
return &ii, nil
|
||||
return i.Identity, nil
|
||||
}
|
||||
|
||||
func (repoResolver) UserIdentity(ctx context.Context, obj *models.Repository) (*identity.Interface, error) {
|
||||
func (repoResolver) UserIdentity(ctx context.Context, obj *models.Repository) (identity.Interface, error) {
|
||||
i, err := obj.Repo.GetUserIdentity()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ii := identity.Interface(i.Identity)
|
||||
|
||||
return &ii, nil
|
||||
return i.Identity, nil
|
||||
}
|
||||
|
@ -10,40 +10,47 @@ import (
|
||||
|
||||
type commentHistoryStepResolver struct{}
|
||||
|
||||
func (commentHistoryStepResolver) Date(ctx context.Context, obj *bug.CommentHistoryStep) (time.Time, error) {
|
||||
return obj.UnixTime.Time(), nil
|
||||
func (commentHistoryStepResolver) Date(ctx context.Context, obj *bug.CommentHistoryStep) (*time.Time, error) {
|
||||
t := obj.UnixTime.Time()
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
type addCommentTimelineItemResolver struct{}
|
||||
|
||||
func (addCommentTimelineItemResolver) CreatedAt(ctx context.Context, obj *bug.AddCommentTimelineItem) (time.Time, error) {
|
||||
return obj.CreatedAt.Time(), nil
|
||||
func (addCommentTimelineItemResolver) CreatedAt(ctx context.Context, obj *bug.AddCommentTimelineItem) (*time.Time, error) {
|
||||
t := obj.CreatedAt.Time()
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
func (addCommentTimelineItemResolver) LastEdit(ctx context.Context, obj *bug.AddCommentTimelineItem) (time.Time, error) {
|
||||
return obj.LastEdit.Time(), nil
|
||||
func (addCommentTimelineItemResolver) LastEdit(ctx context.Context, obj *bug.AddCommentTimelineItem) (*time.Time, error) {
|
||||
t := obj.LastEdit.Time()
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
type createTimelineItemResolver struct{}
|
||||
|
||||
func (createTimelineItemResolver) CreatedAt(ctx context.Context, obj *bug.CreateTimelineItem) (time.Time, error) {
|
||||
return obj.CreatedAt.Time(), nil
|
||||
func (createTimelineItemResolver) CreatedAt(ctx context.Context, obj *bug.CreateTimelineItem) (*time.Time, error) {
|
||||
t := obj.CreatedAt.Time()
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
func (createTimelineItemResolver) LastEdit(ctx context.Context, obj *bug.CreateTimelineItem) (time.Time, error) {
|
||||
return obj.LastEdit.Time(), nil
|
||||
func (createTimelineItemResolver) LastEdit(ctx context.Context, obj *bug.CreateTimelineItem) (*time.Time, error) {
|
||||
t := obj.LastEdit.Time()
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
type labelChangeTimelineItem struct{}
|
||||
|
||||
func (labelChangeTimelineItem) Date(ctx context.Context, obj *bug.LabelChangeTimelineItem) (time.Time, error) {
|
||||
return obj.UnixTime.Time(), nil
|
||||
func (labelChangeTimelineItem) Date(ctx context.Context, obj *bug.LabelChangeTimelineItem) (*time.Time, error) {
|
||||
t := obj.UnixTime.Time()
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
type setStatusTimelineItem struct{}
|
||||
|
||||
func (setStatusTimelineItem) Date(ctx context.Context, obj *bug.SetStatusTimelineItem) (time.Time, error) {
|
||||
return obj.UnixTime.Time(), nil
|
||||
func (setStatusTimelineItem) Date(ctx context.Context, obj *bug.SetStatusTimelineItem) (*time.Time, error) {
|
||||
t := obj.UnixTime.Time()
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
func (setStatusTimelineItem) Status(ctx context.Context, obj *bug.SetStatusTimelineItem) (models.Status, error) {
|
||||
@ -52,6 +59,7 @@ func (setStatusTimelineItem) Status(ctx context.Context, obj *bug.SetStatusTimel
|
||||
|
||||
type setTitleTimelineItem struct{}
|
||||
|
||||
func (setTitleTimelineItem) Date(ctx context.Context, obj *bug.SetTitleTimelineItem) (time.Time, error) {
|
||||
return obj.UnixTime.Time(), nil
|
||||
func (setTitleTimelineItem) Date(ctx context.Context, obj *bug.SetTitleTimelineItem) (*time.Time, error) {
|
||||
t := obj.UnixTime.Time()
|
||||
return &t, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user