Add name and description for task

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-01-28 15:21:35 -08:00
parent 0c55cafd6e
commit e955b4a503
5 changed files with 82 additions and 16 deletions

View File

@@ -135,6 +135,7 @@ type TaskEdge {
type Task implements Node { type Task implements Node {
id: ID! id: ID!
name: String! name: String!
description: String!
createdAt: Datetime! createdAt: Datetime!
updatedAt: Datetime! updatedAt: Datetime!
} }

View File

@@ -130,10 +130,11 @@ type ComplexityRoot struct {
} }
Task struct { Task struct {
CreatedAt func(childComplexity int) int CreatedAt func(childComplexity int) int
ID func(childComplexity int) int Description func(childComplexity int) int
Name func(childComplexity int) int ID func(childComplexity int) int
UpdatedAt func(childComplexity int) int Name func(childComplexity int) int
UpdatedAt func(childComplexity int) int
} }
TaskConnection struct { TaskConnection struct {
@@ -506,6 +507,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Task.CreatedAt(childComplexity), true return e.complexity.Task.CreatedAt(childComplexity), true
case "Task.description":
if e.complexity.Task.Description == nil {
break
}
return e.complexity.Task.Description(childComplexity), true
case "Task.id": case "Task.id":
if e.complexity.Task.ID == nil { if e.complexity.Task.ID == nil {
break break
@@ -781,6 +789,7 @@ type TaskEdge {
type Task implements Node { type Task implements Node {
id: ID! id: ID!
name: String! name: String!
description: String!
createdAt: Datetime! createdAt: Datetime!
updatedAt: Datetime! updatedAt: Datetime!
} }
@@ -3118,6 +3127,44 @@ func (ec *executionContext) fieldContext_Task_name(_ context.Context, field grap
return fc, nil return fc, nil
} }
func (ec *executionContext) _Task_description(ctx context.Context, field graphql.CollectedField, obj *types.Task) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Task_description(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.Description, 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.(string)
fc.Result = res
return ec.marshalNString2string(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Task_description(_ 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 String does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Task_createdAt(ctx context.Context, field graphql.CollectedField, obj *types.Task) (ret graphql.Marshaler) { func (ec *executionContext) _Task_createdAt(ctx context.Context, field graphql.CollectedField, obj *types.Task) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Task_createdAt(ctx, field) fc, err := ec.fieldContext_Task_createdAt(ctx, field)
if err != nil { if err != nil {
@@ -3361,6 +3408,8 @@ func (ec *executionContext) fieldContext_TaskEdge_node(_ context.Context, field
return ec.fieldContext_Task_id(ctx, field) return ec.fieldContext_Task_id(ctx, field)
case "name": case "name":
return ec.fieldContext_Task_name(ctx, field) return ec.fieldContext_Task_name(ctx, field)
case "description":
return ec.fieldContext_Task_description(ctx, field)
case "createdAt": case "createdAt":
return ec.fieldContext_Task_createdAt(ctx, field) return ec.fieldContext_Task_createdAt(ctx, field)
case "updatedAt": case "updatedAt":
@@ -5727,6 +5776,11 @@ func (ec *executionContext) _Task(ctx context.Context, sel ast.SelectionSet, obj
if out.Values[i] == graphql.Null { if out.Values[i] == graphql.Null {
out.Invalids++ out.Invalids++
} }
case "description":
out.Values[i] = ec._Task_description(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "createdAt": case "createdAt":
out.Values[i] = ec._Task_createdAt(ctx, field, obj) out.Values[i] = ec._Task_createdAt(ctx, field, obj)
if out.Values[i] == graphql.Null { if out.Values[i] == graphql.Null {

View File

@@ -41,8 +41,10 @@ func NewTaskEdge(t *coredata.Task) *TaskEdge {
func NewTask(t *coredata.Task) *Task { func NewTask(t *coredata.Task) *Task {
return &Task{ return &Task{
ID: t.ID, ID: t.ID,
CreatedAt: t.CreatedAt, Name: t.Name,
UpdatedAt: t.UpdatedAt, Description: t.Description,
CreatedAt: t.CreatedAt,
UpdatedAt: t.UpdatedAt,
} }
} }

View File

@@ -104,10 +104,11 @@ type Query struct {
} }
type Task struct { type Task struct {
ID gid.GID `json:"id"` ID gid.GID `json:"id"`
Name string `json:"name"` Name string `json:"name"`
CreatedAt time.Time `json:"createdAt"` Description string `json:"description"`
UpdatedAt time.Time `json:"updatedAt"` CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} }
func (Task) IsNode() {} func (Task) IsNode() {}

View File

@@ -30,11 +30,13 @@ import (
type ( type (
Task struct { Task struct {
ID gid.GID ID gid.GID
ControlID gid.GID ControlID gid.GID
ContentRef string Name string
CreatedAt time.Time Description string
UpdatedAt time.Time ContentRef string
CreatedAt time.Time
UpdatedAt time.Time
} }
Tasks []*Task Tasks []*Task
@@ -48,6 +50,8 @@ func (t *Task) scan(r pgx.Row) error {
return r.Scan( return r.Scan(
&t.ID, &t.ID,
&t.ControlID, &t.ControlID,
&t.Name,
&t.Description,
&t.ContentRef, &t.ContentRef,
&t.CreatedAt, &t.CreatedAt,
&t.UpdatedAt, &t.UpdatedAt,
@@ -66,6 +70,8 @@ WITH control_tasks AS (
SELECT SELECT
t.id, t.id,
@control_id AS control_id, @control_id AS control_id,
t.name,
t.description,
t.content_ref, t.content_ref,
t.created_at, t.created_at,
t.updated_at t.updated_at
@@ -81,6 +87,8 @@ WITH control_tasks AS (
SELECT SELECT
id, id,
control_id, control_id,
name,
description,
content_ref, content_ref,
created_at, created_at,
updated_at updated_at