@@ -28,3 +28,6 @@ models:
|
||||
CursorKey:
|
||||
model:
|
||||
- "github.com/getprobo/probo/pkg/server/api/console/v1/types.CursorKeyScalar"
|
||||
Duration:
|
||||
model:
|
||||
- "github.com/99designs/gqlgen/graphql.Duration"
|
||||
|
||||
@@ -15,6 +15,7 @@ scalar CursorKey
|
||||
scalar Void
|
||||
scalar Datetime
|
||||
scalar Upload
|
||||
scalar Duration
|
||||
|
||||
interface Node {
|
||||
id: ID!
|
||||
@@ -261,6 +262,7 @@ type Task implements Node {
|
||||
name: String!
|
||||
description: String!
|
||||
state: TaskState!
|
||||
timeEstimate: Duration!
|
||||
|
||||
evidences(
|
||||
first: Int
|
||||
@@ -485,6 +487,7 @@ input CreateTaskInput {
|
||||
controlId: ID!
|
||||
name: String!
|
||||
description: String!
|
||||
timeEstimate: Duration!
|
||||
}
|
||||
|
||||
type CreateTaskPayload {
|
||||
|
||||
@@ -290,14 +290,15 @@ type ComplexityRoot struct {
|
||||
}
|
||||
|
||||
Task struct {
|
||||
CreatedAt func(childComplexity int) int
|
||||
Description func(childComplexity int) int
|
||||
Evidences func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey) int
|
||||
ID func(childComplexity int) int
|
||||
Name func(childComplexity int) int
|
||||
State func(childComplexity int) int
|
||||
UpdatedAt func(childComplexity int) int
|
||||
Version func(childComplexity int) int
|
||||
CreatedAt func(childComplexity int) int
|
||||
Description func(childComplexity int) int
|
||||
Evidences func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey) int
|
||||
ID func(childComplexity int) int
|
||||
Name func(childComplexity int) int
|
||||
State func(childComplexity int) int
|
||||
TimeEstimate func(childComplexity int) int
|
||||
UpdatedAt func(childComplexity int) int
|
||||
Version func(childComplexity int) int
|
||||
}
|
||||
|
||||
TaskConnection struct {
|
||||
@@ -1495,6 +1496,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||
|
||||
return e.complexity.Task.State(childComplexity), true
|
||||
|
||||
case "Task.timeEstimate":
|
||||
if e.complexity.Task.TimeEstimate == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Task.TimeEstimate(childComplexity), true
|
||||
|
||||
case "Task.updatedAt":
|
||||
if e.complexity.Task.UpdatedAt == nil {
|
||||
break
|
||||
@@ -1904,6 +1912,7 @@ scalar CursorKey
|
||||
scalar Void
|
||||
scalar Datetime
|
||||
scalar Upload
|
||||
scalar Duration
|
||||
|
||||
interface Node {
|
||||
id: ID!
|
||||
@@ -2150,6 +2159,7 @@ type Task implements Node {
|
||||
name: String!
|
||||
description: String!
|
||||
state: TaskState!
|
||||
timeEstimate: Duration!
|
||||
|
||||
evidences(
|
||||
first: Int
|
||||
@@ -2374,6 +2384,7 @@ input CreateTaskInput {
|
||||
controlId: ID!
|
||||
name: String!
|
||||
description: String!
|
||||
timeEstimate: Duration!
|
||||
}
|
||||
|
||||
type CreateTaskPayload {
|
||||
@@ -9313,6 +9324,44 @@ func (ec *executionContext) fieldContext_Task_state(_ context.Context, field gra
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Task_timeEstimate(ctx context.Context, field graphql.CollectedField, obj *types.Task) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Task_timeEstimate(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return obj.TimeEstimate, nil
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
if !graphql.HasFieldError(ctx, fc) {
|
||||
ec.Errorf(ctx, "must not be null")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(time.Duration)
|
||||
fc.Result = res
|
||||
return ec.marshalNDuration2timeᚐDuration(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Task_timeEstimate(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "Task",
|
||||
Field: field,
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type Duration does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Task_evidences(ctx context.Context, field graphql.CollectedField, obj *types.Task) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Task_evidences(ctx, field)
|
||||
if err != nil {
|
||||
@@ -9611,6 +9660,8 @@ func (ec *executionContext) fieldContext_TaskEdge_node(_ context.Context, field
|
||||
return ec.fieldContext_Task_description(ctx, field)
|
||||
case "state":
|
||||
return ec.fieldContext_Task_state(ctx, field)
|
||||
case "timeEstimate":
|
||||
return ec.fieldContext_Task_timeEstimate(ctx, field)
|
||||
case "evidences":
|
||||
return ec.fieldContext_Task_evidences(ctx, field)
|
||||
case "createdAt":
|
||||
@@ -9953,6 +10004,8 @@ func (ec *executionContext) fieldContext_UpdateTaskPayload_task(_ context.Contex
|
||||
return ec.fieldContext_Task_description(ctx, field)
|
||||
case "state":
|
||||
return ec.fieldContext_Task_state(ctx, field)
|
||||
case "timeEstimate":
|
||||
return ec.fieldContext_Task_timeEstimate(ctx, field)
|
||||
case "evidences":
|
||||
return ec.fieldContext_Task_evidences(ctx, field)
|
||||
case "createdAt":
|
||||
@@ -12966,7 +13019,7 @@ func (ec *executionContext) unmarshalInputCreateTaskInput(ctx context.Context, o
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"controlId", "name", "description"}
|
||||
fieldsInOrder := [...]string{"controlId", "name", "description", "timeEstimate"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
@@ -12994,6 +13047,13 @@ func (ec *executionContext) unmarshalInputCreateTaskInput(ctx context.Context, o
|
||||
return it, err
|
||||
}
|
||||
it.Description = data
|
||||
case "timeEstimate":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("timeEstimate"))
|
||||
data, err := ec.unmarshalNDuration2timeᚐDuration(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.TimeEstimate = data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16040,6 +16100,11 @@ func (ec *executionContext) _Task(ctx context.Context, sel ast.SelectionSet, obj
|
||||
if out.Values[i] == graphql.Null {
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
}
|
||||
case "timeEstimate":
|
||||
out.Values[i] = ec._Task_timeEstimate(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
atomic.AddUint32(&out.Invalids, 1)
|
||||
}
|
||||
case "evidences":
|
||||
field := field
|
||||
|
||||
@@ -17547,6 +17612,21 @@ func (ec *executionContext) marshalNDeleteVendorPayload2ᚖgithubᚗcomᚋgetpro
|
||||
return ec._DeleteVendorPayload(ctx, sel, v)
|
||||
}
|
||||
|
||||
func (ec *executionContext) unmarshalNDuration2timeᚐDuration(ctx context.Context, v any) (time.Duration, error) {
|
||||
res, err := graphql.UnmarshalDuration(v)
|
||||
return res, graphql.ErrorOnPath(ctx, err)
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalNDuration2timeᚐDuration(ctx context.Context, sel ast.SelectionSet, v time.Duration) graphql.Marshaler {
|
||||
res := graphql.MarshalDuration(v)
|
||||
if res == graphql.Null {
|
||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func (ec *executionContext) marshalNEvidence2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐEvidence(ctx context.Context, sel ast.SelectionSet, v *types.Evidence) graphql.Marshaler {
|
||||
if v == nil {
|
||||
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||
|
||||
@@ -41,12 +41,13 @@ func NewTaskEdge(t *coredata.Task) *TaskEdge {
|
||||
|
||||
func NewTask(t *coredata.Task) *Task {
|
||||
return &Task{
|
||||
ID: t.ID,
|
||||
Name: t.Name,
|
||||
Description: t.Description,
|
||||
State: t.State,
|
||||
CreatedAt: t.CreatedAt,
|
||||
UpdatedAt: t.UpdatedAt,
|
||||
Version: t.Version,
|
||||
ID: t.ID,
|
||||
Name: t.Name,
|
||||
Description: t.Description,
|
||||
State: t.State,
|
||||
TimeEstimate: t.TimeEstimate,
|
||||
CreatedAt: t.CreatedAt,
|
||||
UpdatedAt: t.UpdatedAt,
|
||||
Version: t.Version,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,9 +106,10 @@ type CreatePolicyPayload struct {
|
||||
}
|
||||
|
||||
type CreateTaskInput struct {
|
||||
ControlID gid.GID `json:"controlId"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
ControlID gid.GID `json:"controlId"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
TimeEstimate time.Duration `json:"timeEstimate"`
|
||||
}
|
||||
|
||||
type CreateTaskPayload struct {
|
||||
@@ -329,14 +330,15 @@ type Session struct {
|
||||
}
|
||||
|
||||
type Task struct {
|
||||
ID gid.GID `json:"id"`
|
||||
Version int `json:"version"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
State coredata.TaskState `json:"state"`
|
||||
Evidences *EvidenceConnection `json:"evidences"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
ID gid.GID `json:"id"`
|
||||
Version int `json:"version"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
State coredata.TaskState `json:"state"`
|
||||
TimeEstimate time.Duration `json:"timeEstimate"`
|
||||
Evidences *EvidenceConnection `json:"evidences"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (Task) IsNode() {}
|
||||
|
||||
@@ -207,9 +207,10 @@ func (r *mutationResolver) CreateTask(ctx context.Context, input types.CreateTas
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, input.ControlID.TenantID())
|
||||
|
||||
task, err := svc.Tasks.Create(ctx, probo.CreateTaskRequest{
|
||||
ControlID: input.ControlID,
|
||||
Name: input.Name,
|
||||
Description: input.Description,
|
||||
ControlID: input.ControlID,
|
||||
Name: input.Name,
|
||||
Description: input.Description,
|
||||
TimeEstimate: input.TimeEstimate,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot create task: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user