mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-15 10:12:06 +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,
|
edges []EdgeType,
|
||||||
nodes []NodeType,
|
nodes []NodeType,
|
||||||
info models.PageInfo,
|
info models.PageInfo,
|
||||||
totalCount int) (ConnectionType, error)
|
totalCount int) (*ConnectionType, error)
|
||||||
|
|
||||||
// NameCon will paginate a source according to the input of a relay connection
|
// 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 nodes []NodeType
|
||||||
var edges []EdgeType
|
var edges []EdgeType
|
||||||
var cursors []string
|
var cursors []string
|
||||||
|
@ -20,10 +20,10 @@ type CommentConMaker func(
|
|||||||
edges []models.CommentEdge,
|
edges []models.CommentEdge,
|
||||||
nodes []bug.Comment,
|
nodes []bug.Comment,
|
||||||
info models.PageInfo,
|
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
|
// 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 nodes []bug.Comment
|
||||||
var edges []models.CommentEdge
|
var edges []models.CommentEdge
|
||||||
var cursors []string
|
var cursors []string
|
||||||
|
@ -20,10 +20,10 @@ type IdentityConMaker func(
|
|||||||
edges []models.IdentityEdge,
|
edges []models.IdentityEdge,
|
||||||
nodes []identity.Interface,
|
nodes []identity.Interface,
|
||||||
info models.PageInfo,
|
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
|
// 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 nodes []identity.Interface
|
||||||
var edges []models.IdentityEdge
|
var edges []models.IdentityEdge
|
||||||
var cursors []string
|
var cursors []string
|
||||||
|
@ -19,10 +19,10 @@ type LazyBugConMaker func(
|
|||||||
edges []LazyBugEdge,
|
edges []LazyBugEdge,
|
||||||
nodes []string,
|
nodes []string,
|
||||||
info models.PageInfo,
|
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
|
// 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 nodes []string
|
||||||
var edges []LazyBugEdge
|
var edges []LazyBugEdge
|
||||||
var cursors []string
|
var cursors []string
|
||||||
|
@ -19,10 +19,10 @@ type LazyIdentityConMaker func(
|
|||||||
edges []LazyIdentityEdge,
|
edges []LazyIdentityEdge,
|
||||||
nodes []string,
|
nodes []string,
|
||||||
info models.PageInfo,
|
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
|
// 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 nodes []string
|
||||||
var edges []LazyIdentityEdge
|
var edges []LazyIdentityEdge
|
||||||
var cursors []string
|
var cursors []string
|
||||||
|
@ -20,10 +20,10 @@ type OperationConMaker func(
|
|||||||
edges []models.OperationEdge,
|
edges []models.OperationEdge,
|
||||||
nodes []bug.Operation,
|
nodes []bug.Operation,
|
||||||
info models.PageInfo,
|
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
|
// 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 nodes []bug.Operation
|
||||||
var edges []models.OperationEdge
|
var edges []models.OperationEdge
|
||||||
var cursors []string
|
var cursors []string
|
||||||
|
@ -20,10 +20,10 @@ type TimelineItemConMaker func(
|
|||||||
edges []models.TimelineItemEdge,
|
edges []models.TimelineItemEdge,
|
||||||
nodes []bug.TimelineItem,
|
nodes []bug.TimelineItem,
|
||||||
info models.PageInfo,
|
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
|
// 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 nodes []bug.TimelineItem
|
||||||
var edges []models.TimelineItemEdge
|
var edges []models.TimelineItemEdge
|
||||||
var cursors []string
|
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.
|
// The connection type for Bug.
|
||||||
type BugConnection struct {
|
type BugConnection struct {
|
||||||
|
// A list of edges.
|
||||||
Edges []BugEdge `json:"edges"`
|
Edges []BugEdge `json:"edges"`
|
||||||
Nodes []bug.Snapshot `json:"nodes"`
|
Nodes []bug.Snapshot `json:"nodes"`
|
||||||
|
// Information to aid in pagination.
|
||||||
PageInfo PageInfo `json:"pageInfo"`
|
PageInfo PageInfo `json:"pageInfo"`
|
||||||
|
// Identifies the total count of items in the connection.
|
||||||
TotalCount int `json:"totalCount"`
|
TotalCount int `json:"totalCount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// An edge in a connection.
|
// An edge in a connection.
|
||||||
type BugEdge struct {
|
type BugEdge struct {
|
||||||
|
// A cursor for use in pagination.
|
||||||
Cursor string `json:"cursor"`
|
Cursor string `json:"cursor"`
|
||||||
|
// The item at the end of the edge.
|
||||||
Node bug.Snapshot `json:"node"`
|
Node bug.Snapshot `json:"node"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,9 +75,13 @@ type OperationEdge struct {
|
|||||||
|
|
||||||
// Information about pagination in a connection.
|
// Information about pagination in a connection.
|
||||||
type PageInfo struct {
|
type PageInfo struct {
|
||||||
|
// When paginating forwards, are there more items?
|
||||||
HasNextPage bool `json:"hasNextPage"`
|
HasNextPage bool `json:"hasNextPage"`
|
||||||
|
// When paginating backwards, are there more items?
|
||||||
HasPreviousPage bool `json:"hasPreviousPage"`
|
HasPreviousPage bool `json:"hasPreviousPage"`
|
||||||
|
// When paginating backwards, the cursor to continue.
|
||||||
StartCursor string `json:"startCursor"`
|
StartCursor string `json:"startCursor"`
|
||||||
|
// When paginating forwards, the cursor to continue.
|
||||||
EndCursor string `json:"endCursor"`
|
EndCursor string `json:"endCursor"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,6 +106,11 @@ const (
|
|||||||
StatusClosed Status = "CLOSED"
|
StatusClosed Status = "CLOSED"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var AllStatus = []Status{
|
||||||
|
StatusOpen,
|
||||||
|
StatusClosed,
|
||||||
|
}
|
||||||
|
|
||||||
func (e Status) IsValid() bool {
|
func (e Status) IsValid() bool {
|
||||||
switch e {
|
switch e {
|
||||||
case StatusOpen, StatusClosed:
|
case StatusOpen, StatusClosed:
|
||||||
|
@ -19,7 +19,7 @@ func (bugResolver) Status(ctx context.Context, obj *bug.Snapshot) (models.Status
|
|||||||
return convertStatus(obj.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{
|
input := models.ConnectionInput{
|
||||||
Before: before,
|
Before: before,
|
||||||
After: after,
|
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) {
|
conMaker := func(edges []models.CommentEdge, nodes []bug.Comment, info models.PageInfo, totalCount int) (*models.CommentConnection, error) {
|
||||||
return models.CommentConnection{
|
return &models.CommentConnection{
|
||||||
Edges: edges,
|
Edges: edges,
|
||||||
Nodes: nodes,
|
Nodes: nodes,
|
||||||
PageInfo: info,
|
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)
|
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{
|
input := models.ConnectionInput{
|
||||||
Before: before,
|
Before: before,
|
||||||
After: after,
|
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) {
|
conMaker := func(edges []models.OperationEdge, nodes []bug.Operation, info models.PageInfo, totalCount int) (*models.OperationConnection, error) {
|
||||||
return models.OperationConnection{
|
return &models.OperationConnection{
|
||||||
Edges: edges,
|
Edges: edges,
|
||||||
Nodes: nodes,
|
Nodes: nodes,
|
||||||
PageInfo: info,
|
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)
|
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{
|
input := models.ConnectionInput{
|
||||||
Before: before,
|
Before: before,
|
||||||
After: after,
|
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) {
|
conMaker := func(edges []models.TimelineItemEdge, nodes []bug.TimelineItem, info models.PageInfo, totalCount int) (*models.TimelineItemConnection, error) {
|
||||||
return models.TimelineItemConnection{
|
return &models.TimelineItemConnection{
|
||||||
Edges: edges,
|
Edges: edges,
|
||||||
Nodes: nodes,
|
Nodes: nodes,
|
||||||
PageInfo: info,
|
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)
|
return connections.TimelineItemCon(obj.Timeline, edger, conMaker, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bugResolver) LastEdit(ctx context.Context, obj *bug.Snapshot) (time.Time, error) {
|
func (bugResolver) LastEdit(ctx context.Context, obj *bug.Snapshot) (*time.Time, error) {
|
||||||
return obj.LastEditTime(), nil
|
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{
|
input := models.ConnectionInput{
|
||||||
Before: before,
|
Before: before,
|
||||||
After: after,
|
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) {
|
conMaker := func(edges []models.IdentityEdge, nodes []identity.Interface, info models.PageInfo, totalCount int) (*models.IdentityConnection, error) {
|
||||||
return models.IdentityConnection{
|
return &models.IdentityConnection{
|
||||||
Edges: edges,
|
Edges: edges,
|
||||||
Nodes: nodes,
|
Nodes: nodes,
|
||||||
PageInfo: info,
|
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)
|
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{
|
input := models.ConnectionInput{
|
||||||
Before: before,
|
Before: before,
|
||||||
After: after,
|
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) {
|
conMaker := func(edges []models.IdentityEdge, nodes []identity.Interface, info models.PageInfo, totalCount int) (*models.IdentityConnection, error) {
|
||||||
return models.IdentityConnection{
|
return &models.IdentityConnection{
|
||||||
Edges: edges,
|
Edges: edges,
|
||||||
Nodes: nodes,
|
Nodes: nodes,
|
||||||
PageInfo: info,
|
PageInfo: info,
|
||||||
|
@ -23,144 +23,130 @@ func (r mutationResolver) getRepo(repoRef *string) (*cache.RepoCache, error) {
|
|||||||
return r.cache.DefaultRepo()
|
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)
|
repo, err := r.getRepo(repoRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := repo.NewBugWithFiles(title, message, files)
|
b, err := repo.NewBugWithFiles(title, message, files)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
snap := b.Snapshot()
|
return b.Snapshot(), nil
|
||||||
|
|
||||||
return *snap, 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)
|
repo, err := r.getRepo(repoRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := repo.ResolveBugPrefix(prefix)
|
b, err := repo.ResolveBugPrefix(prefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = b.Commit()
|
err = b.Commit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
snap := b.Snapshot()
|
return b.Snapshot(), nil
|
||||||
|
|
||||||
return *snap, 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)
|
repo, err := r.getRepo(repoRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := repo.ResolveBugPrefix(prefix)
|
b, err := repo.ResolveBugPrefix(prefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = b.AddCommentWithFiles(message, files)
|
_, err = b.AddCommentWithFiles(message, files)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
snap := b.Snapshot()
|
return b.Snapshot(), nil
|
||||||
|
|
||||||
return *snap, 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)
|
repo, err := r.getRepo(repoRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := repo.ResolveBugPrefix(prefix)
|
b, err := repo.ResolveBugPrefix(prefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _, err = b.ChangeLabels(added, removed)
|
_, _, err = b.ChangeLabels(added, removed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
snap := b.Snapshot()
|
return b.Snapshot(), nil
|
||||||
|
|
||||||
return *snap, 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)
|
repo, err := r.getRepo(repoRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := repo.ResolveBugPrefix(prefix)
|
b, err := repo.ResolveBugPrefix(prefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = b.Open()
|
_, err = b.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
snap := b.Snapshot()
|
return b.Snapshot(), nil
|
||||||
|
|
||||||
return *snap, 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)
|
repo, err := r.getRepo(repoRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := repo.ResolveBugPrefix(prefix)
|
b, err := repo.ResolveBugPrefix(prefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = b.Close()
|
_, err = b.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
snap := b.Snapshot()
|
return b.Snapshot(), nil
|
||||||
|
|
||||||
return *snap, 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)
|
repo, err := r.getRepo(repoRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := repo.ResolveBugPrefix(prefix)
|
b, err := repo.ResolveBugPrefix(prefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = b.SetTitle(title)
|
_, err = b.SetTitle(title)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bug.Snapshot{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
snap := b.Snapshot()
|
return b.Snapshot(), nil
|
||||||
|
|
||||||
return *snap, nil
|
|
||||||
}
|
}
|
||||||
|
@ -11,32 +11,37 @@ import (
|
|||||||
|
|
||||||
type createOperationResolver struct{}
|
type createOperationResolver struct{}
|
||||||
|
|
||||||
func (createOperationResolver) Date(ctx context.Context, obj *bug.CreateOperation) (time.Time, error) {
|
func (createOperationResolver) Date(ctx context.Context, obj *bug.CreateOperation) (*time.Time, error) {
|
||||||
return obj.Time(), nil
|
t := obj.Time()
|
||||||
|
return &t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type addCommentOperationResolver struct{}
|
type addCommentOperationResolver struct{}
|
||||||
|
|
||||||
func (addCommentOperationResolver) Date(ctx context.Context, obj *bug.AddCommentOperation) (time.Time, error) {
|
func (addCommentOperationResolver) Date(ctx context.Context, obj *bug.AddCommentOperation) (*time.Time, error) {
|
||||||
return obj.Time(), nil
|
t := obj.Time()
|
||||||
|
return &t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type editCommentOperationResolver struct{}
|
type editCommentOperationResolver struct{}
|
||||||
|
|
||||||
func (editCommentOperationResolver) Date(ctx context.Context, obj *bug.EditCommentOperation) (time.Time, error) {
|
func (editCommentOperationResolver) Date(ctx context.Context, obj *bug.EditCommentOperation) (*time.Time, error) {
|
||||||
return obj.Time(), nil
|
t := obj.Time()
|
||||||
|
return &t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type labelChangeOperation struct{}
|
type labelChangeOperation struct{}
|
||||||
|
|
||||||
func (labelChangeOperation) Date(ctx context.Context, obj *bug.LabelChangeOperation) (time.Time, error) {
|
func (labelChangeOperation) Date(ctx context.Context, obj *bug.LabelChangeOperation) (*time.Time, error) {
|
||||||
return obj.Time(), nil
|
t := obj.Time()
|
||||||
|
return &t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type setStatusOperationResolver struct{}
|
type setStatusOperationResolver struct{}
|
||||||
|
|
||||||
func (setStatusOperationResolver) Date(ctx context.Context, obj *bug.SetStatusOperation) (time.Time, error) {
|
func (setStatusOperationResolver) Date(ctx context.Context, obj *bug.SetStatusOperation) (*time.Time, error) {
|
||||||
return obj.Time(), nil
|
t := obj.Time()
|
||||||
|
return &t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (setStatusOperationResolver) Status(ctx context.Context, obj *bug.SetStatusOperation) (models.Status, error) {
|
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{}
|
type setTitleOperationResolver struct{}
|
||||||
|
|
||||||
func (setTitleOperationResolver) Date(ctx context.Context, obj *bug.SetTitleOperation) (time.Time, error) {
|
func (setTitleOperationResolver) Date(ctx context.Context, obj *bug.SetTitleOperation) (*time.Time, error) {
|
||||||
return obj.Time(), nil
|
t := obj.Time()
|
||||||
|
return &t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertStatus(status bug.Status) (models.Status, error) {
|
func convertStatus(status bug.Status) (models.Status, error) {
|
||||||
|
@ -15,7 +15,7 @@ var _ graph.RepositoryResolver = &repoResolver{}
|
|||||||
|
|
||||||
type repoResolver struct{}
|
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{
|
input := models.ConnectionInput{
|
||||||
Before: before,
|
Before: before,
|
||||||
After: after,
|
After: after,
|
||||||
@ -27,7 +27,7 @@ func (repoResolver) AllBugs(ctx context.Context, obj *models.Repository, after *
|
|||||||
if queryStr != nil {
|
if queryStr != nil {
|
||||||
query2, err := cache.ParseQuery(*queryStr)
|
query2, err := cache.ParseQuery(*queryStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return models.BugConnection{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
query = query2
|
query = query2
|
||||||
} else {
|
} 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
|
// 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))
|
edges := make([]models.BugEdge, len(lazyBugEdges))
|
||||||
nodes := make([]bug.Snapshot, 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)
|
b, err := obj.Repo.ResolveBug(lazyBugEdge.Id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return models.BugConnection{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
snap := b.Snapshot()
|
snap := b.Snapshot()
|
||||||
@ -66,7 +66,7 @@ func (repoResolver) AllBugs(ctx context.Context, obj *models.Repository, after *
|
|||||||
nodes[i] = *snap
|
nodes[i] = *snap
|
||||||
}
|
}
|
||||||
|
|
||||||
return models.BugConnection{
|
return &models.BugConnection{
|
||||||
Edges: edges,
|
Edges: edges,
|
||||||
Nodes: nodes,
|
Nodes: nodes,
|
||||||
PageInfo: info,
|
PageInfo: info,
|
||||||
@ -87,7 +87,7 @@ func (repoResolver) Bug(ctx context.Context, obj *models.Repository, prefix stri
|
|||||||
return b.Snapshot(), nil
|
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{
|
input := models.ConnectionInput{
|
||||||
Before: before,
|
Before: before,
|
||||||
After: after,
|
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
|
// 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))
|
edges := make([]models.IdentityEdge, len(lazyIdentityEdges))
|
||||||
nodes := make([]identity.Interface, 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)
|
i, err := obj.Repo.ResolveIdentity(lazyIdentityEdge.Id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return models.IdentityConnection{}, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ii := identity.Interface(i.Identity)
|
ii := identity.Interface(i.Identity)
|
||||||
@ -127,7 +127,7 @@ func (repoResolver) AllIdentities(ctx context.Context, obj *models.Repository, a
|
|||||||
nodes[k] = ii
|
nodes[k] = ii
|
||||||
}
|
}
|
||||||
|
|
||||||
return models.IdentityConnection{
|
return &models.IdentityConnection{
|
||||||
Edges: edges,
|
Edges: edges,
|
||||||
Nodes: nodes,
|
Nodes: nodes,
|
||||||
PageInfo: info,
|
PageInfo: info,
|
||||||
@ -138,26 +138,22 @@ func (repoResolver) AllIdentities(ctx context.Context, obj *models.Repository, a
|
|||||||
return connections.LazyIdentityCon(source, edger, conMaker, input)
|
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)
|
i, err := obj.Repo.ResolveIdentityPrefix(prefix)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ii := identity.Interface(i.Identity)
|
return i.Identity, nil
|
||||||
|
|
||||||
return &ii, 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()
|
i, err := obj.Repo.GetUserIdentity()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ii := identity.Interface(i.Identity)
|
return i.Identity, nil
|
||||||
|
|
||||||
return &ii, nil
|
|
||||||
}
|
}
|
||||||
|
@ -10,40 +10,47 @@ import (
|
|||||||
|
|
||||||
type commentHistoryStepResolver struct{}
|
type commentHistoryStepResolver struct{}
|
||||||
|
|
||||||
func (commentHistoryStepResolver) Date(ctx context.Context, obj *bug.CommentHistoryStep) (time.Time, error) {
|
func (commentHistoryStepResolver) Date(ctx context.Context, obj *bug.CommentHistoryStep) (*time.Time, error) {
|
||||||
return obj.UnixTime.Time(), nil
|
t := obj.UnixTime.Time()
|
||||||
|
return &t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type addCommentTimelineItemResolver struct{}
|
type addCommentTimelineItemResolver struct{}
|
||||||
|
|
||||||
func (addCommentTimelineItemResolver) CreatedAt(ctx context.Context, obj *bug.AddCommentTimelineItem) (time.Time, error) {
|
func (addCommentTimelineItemResolver) CreatedAt(ctx context.Context, obj *bug.AddCommentTimelineItem) (*time.Time, error) {
|
||||||
return obj.CreatedAt.Time(), nil
|
t := obj.CreatedAt.Time()
|
||||||
|
return &t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (addCommentTimelineItemResolver) LastEdit(ctx context.Context, obj *bug.AddCommentTimelineItem) (time.Time, error) {
|
func (addCommentTimelineItemResolver) LastEdit(ctx context.Context, obj *bug.AddCommentTimelineItem) (*time.Time, error) {
|
||||||
return obj.LastEdit.Time(), nil
|
t := obj.LastEdit.Time()
|
||||||
|
return &t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type createTimelineItemResolver struct{}
|
type createTimelineItemResolver struct{}
|
||||||
|
|
||||||
func (createTimelineItemResolver) CreatedAt(ctx context.Context, obj *bug.CreateTimelineItem) (time.Time, error) {
|
func (createTimelineItemResolver) CreatedAt(ctx context.Context, obj *bug.CreateTimelineItem) (*time.Time, error) {
|
||||||
return obj.CreatedAt.Time(), nil
|
t := obj.CreatedAt.Time()
|
||||||
|
return &t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (createTimelineItemResolver) LastEdit(ctx context.Context, obj *bug.CreateTimelineItem) (time.Time, error) {
|
func (createTimelineItemResolver) LastEdit(ctx context.Context, obj *bug.CreateTimelineItem) (*time.Time, error) {
|
||||||
return obj.LastEdit.Time(), nil
|
t := obj.LastEdit.Time()
|
||||||
|
return &t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type labelChangeTimelineItem struct{}
|
type labelChangeTimelineItem struct{}
|
||||||
|
|
||||||
func (labelChangeTimelineItem) Date(ctx context.Context, obj *bug.LabelChangeTimelineItem) (time.Time, error) {
|
func (labelChangeTimelineItem) Date(ctx context.Context, obj *bug.LabelChangeTimelineItem) (*time.Time, error) {
|
||||||
return obj.UnixTime.Time(), nil
|
t := obj.UnixTime.Time()
|
||||||
|
return &t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type setStatusTimelineItem struct{}
|
type setStatusTimelineItem struct{}
|
||||||
|
|
||||||
func (setStatusTimelineItem) Date(ctx context.Context, obj *bug.SetStatusTimelineItem) (time.Time, error) {
|
func (setStatusTimelineItem) Date(ctx context.Context, obj *bug.SetStatusTimelineItem) (*time.Time, error) {
|
||||||
return obj.UnixTime.Time(), nil
|
t := obj.UnixTime.Time()
|
||||||
|
return &t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (setStatusTimelineItem) Status(ctx context.Context, obj *bug.SetStatusTimelineItem) (models.Status, error) {
|
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{}
|
type setTitleTimelineItem struct{}
|
||||||
|
|
||||||
func (setTitleTimelineItem) Date(ctx context.Context, obj *bug.SetTitleTimelineItem) (time.Time, error) {
|
func (setTitleTimelineItem) Date(ctx context.Context, obj *bug.SetTitleTimelineItem) (*time.Time, error) {
|
||||||
return obj.UnixTime.Time(), nil
|
t := obj.UnixTime.Time()
|
||||||
|
return &t, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user