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 {
id: ID!
name: String!
description: String!
createdAt: Datetime!
updatedAt: Datetime!
}

View File

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

View File

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

View File

@@ -106,6 +106,7 @@ type Query struct {
type Task struct {
ID gid.GID `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}

View File

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