30
pkg/api/console/v1/types/task.go
Normal file
30
pkg/api/console/v1/types/task.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/getprobo/probo/pkg/probo/coredata"
|
||||
"github.com/getprobo/probo/pkg/probo/coredata/page"
|
||||
)
|
||||
|
||||
func NewTaskConnection(p *page.Page[*coredata.Task]) *TaskConnection {
|
||||
var edges = make([]*TaskEdge, len(p.Data))
|
||||
|
||||
for i := range edges {
|
||||
edges[i] = NewTaskEdge(p.Data[i])
|
||||
}
|
||||
|
||||
return &TaskConnection{
|
||||
Edges: edges,
|
||||
PageInfo: NewPageInfo(p),
|
||||
}
|
||||
}
|
||||
|
||||
func NewTaskEdge(f *coredata.Task) *TaskEdge {
|
||||
return &TaskEdge{
|
||||
Cursor: f.CursorKey(),
|
||||
Node: NewTask(f),
|
||||
}
|
||||
}
|
||||
|
||||
func NewTask(e *coredata.Task) *Task {
|
||||
return &Task{}
|
||||
}
|
||||
@@ -15,7 +15,14 @@ import (
|
||||
|
||||
// Tasks is the resolver for the tasks field.
|
||||
func (r *controlResolver) Tasks(ctx context.Context, obj *types.Control, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.TaskConnection, error) {
|
||||
panic(fmt.Errorf("not implemented: Tasks - tasks"))
|
||||
cursor := types.NewCursor(first, after, last, before)
|
||||
|
||||
page, err := r.svc.ListControlTasks(ctx, obj.ID, cursor)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot list framework controls: %w", err)
|
||||
}
|
||||
|
||||
return types.NewTaskConnection(page), nil
|
||||
}
|
||||
|
||||
// Controls is the resolver for the controls field.
|
||||
|
||||
Reference in New Issue
Block a user