Add risk proba and impact

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-03-31 09:49:35 +02:00
parent 835bab3113
commit 7d38882e1f
15 changed files with 421 additions and 36 deletions

View File

@@ -346,7 +346,9 @@ type ComplexityRoot struct {
CreatedAt func(childComplexity int) int
Description func(childComplexity int) int
ID func(childComplexity int) int
Impact func(childComplexity int) int
Name func(childComplexity int) int
Probability func(childComplexity int) int
UpdatedAt func(childComplexity int) int
}
@@ -1824,6 +1826,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Risk.ID(childComplexity), true
case "Risk.impact":
if e.complexity.Risk.Impact == nil {
break
}
return e.complexity.Risk.Impact(childComplexity), true
case "Risk.name":
if e.complexity.Risk.Name == nil {
break
@@ -1831,6 +1840,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Risk.Name(childComplexity), true
case "Risk.probability":
if e.complexity.Risk.Probability == nil {
break
}
return e.complexity.Risk.Probability(childComplexity), true
case "Risk.updatedAt":
if e.complexity.Risk.UpdatedAt == nil {
break
@@ -2912,6 +2928,8 @@ type Risk implements Node {
id: ID!
name: String!
description: String!
probability: Float!
impact: Float!
createdAt: Datetime!
updatedAt: Datetime!
}
@@ -3252,12 +3270,16 @@ input CreateRiskInput {
organizationId: ID!
name: String!
description: String!
probability: Float!
impact: Float!
}
input UpdateRiskInput {
id: ID!
name: String
description: String
probability: Float
impact: Float
}
input DeleteRiskInput {
@@ -13082,6 +13104,94 @@ func (ec *executionContext) fieldContext_Risk_description(_ context.Context, fie
return fc, nil
}
func (ec *executionContext) _Risk_probability(ctx context.Context, field graphql.CollectedField, obj *types.Risk) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Risk_probability(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
ctx = rctx // use context from middleware stack in children
return obj.Probability, 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.(float64)
fc.Result = res
return ec.marshalNFloat2float64(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Risk_probability(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Risk",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Float does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Risk_impact(ctx context.Context, field graphql.CollectedField, obj *types.Risk) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Risk_impact(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
ctx = rctx // use context from middleware stack in children
return obj.Impact, 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.(float64)
fc.Result = res
return ec.marshalNFloat2float64(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Risk_impact(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Risk",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Float does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Risk_createdAt(ctx context.Context, field graphql.CollectedField, obj *types.Risk) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Risk_createdAt(ctx, field)
if err != nil {
@@ -13363,6 +13473,10 @@ func (ec *executionContext) fieldContext_RiskEdge_node(_ context.Context, field
return ec.fieldContext_Risk_name(ctx, field)
case "description":
return ec.fieldContext_Risk_description(ctx, field)
case "probability":
return ec.fieldContext_Risk_probability(ctx, field)
case "impact":
return ec.fieldContext_Risk_impact(ctx, field)
case "createdAt":
return ec.fieldContext_Risk_createdAt(ctx, field)
case "updatedAt":
@@ -14520,6 +14634,10 @@ func (ec *executionContext) fieldContext_UpdateRiskPayload_risk(_ context.Contex
return ec.fieldContext_Risk_name(ctx, field)
case "description":
return ec.fieldContext_Risk_description(ctx, field)
case "probability":
return ec.fieldContext_Risk_probability(ctx, field)
case "impact":
return ec.fieldContext_Risk_impact(ctx, field)
case "createdAt":
return ec.fieldContext_Risk_createdAt(ctx, field)
case "updatedAt":
@@ -18327,7 +18445,7 @@ func (ec *executionContext) unmarshalInputCreateRiskInput(ctx context.Context, o
asMap[k] = v
}
fieldsInOrder := [...]string{"organizationId", "name", "description"}
fieldsInOrder := [...]string{"organizationId", "name", "description", "probability", "impact"}
for _, k := range fieldsInOrder {
v, ok := asMap[k]
if !ok {
@@ -18355,6 +18473,20 @@ func (ec *executionContext) unmarshalInputCreateRiskInput(ctx context.Context, o
return it, err
}
it.Description = data
case "probability":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("probability"))
data, err := ec.unmarshalNFloat2float64(ctx, v)
if err != nil {
return it, err
}
it.Probability = data
case "impact":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("impact"))
data, err := ec.unmarshalNFloat2float64(ctx, v)
if err != nil {
return it, err
}
it.Impact = data
}
}
@@ -19432,7 +19564,7 @@ func (ec *executionContext) unmarshalInputUpdateRiskInput(ctx context.Context, o
asMap[k] = v
}
fieldsInOrder := [...]string{"id", "name", "description"}
fieldsInOrder := [...]string{"id", "name", "description", "probability", "impact"}
for _, k := range fieldsInOrder {
v, ok := asMap[k]
if !ok {
@@ -19460,6 +19592,20 @@ func (ec *executionContext) unmarshalInputUpdateRiskInput(ctx context.Context, o
return it, err
}
it.Description = data
case "probability":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("probability"))
data, err := ec.unmarshalOFloat2ᚖfloat64(ctx, v)
if err != nil {
return it, err
}
it.Probability = data
case "impact":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("impact"))
data, err := ec.unmarshalOFloat2ᚖfloat64(ctx, v)
if err != nil {
return it, err
}
it.Impact = data
}
}
@@ -22636,6 +22782,16 @@ func (ec *executionContext) _Risk(ctx context.Context, sel ast.SelectionSet, obj
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "probability":
out.Values[i] = ec._Risk_probability(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "impact":
out.Values[i] = ec._Risk_impact(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "createdAt":
out.Values[i] = ec._Risk_createdAt(ctx, field, obj)
if out.Values[i] == graphql.Null {
@@ -24786,6 +24942,21 @@ var (
}
)
func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v any) (float64, error) {
res, err := graphql.UnmarshalFloatContext(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler {
res := graphql.MarshalFloatContext(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 graphql.WrapContextMarshaler(ctx, res)
}
func (ec *executionContext) marshalNFramework2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐFramework(ctx context.Context, sel ast.SelectionSet, v *types.Framework) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
@@ -26640,6 +26811,22 @@ func (ec *executionContext) unmarshalOEvidenceOrder2ᚖgithubᚗcomᚋgetprobo
return &res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) unmarshalOFloat2ᚖfloat64(ctx context.Context, v any) (*float64, error) {
if v == nil {
return nil, nil
}
res, err := graphql.UnmarshalFloatContext(ctx, v)
return &res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalOFloat2ᚖfloat64(ctx context.Context, sel ast.SelectionSet, v *float64) graphql.Marshaler {
if v == nil {
return graphql.Null
}
res := graphql.MarshalFloatContext(*v)
return graphql.WrapContextMarshaler(ctx, res)
}
func (ec *executionContext) unmarshalOFrameworkOrder2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐFrameworkOrderBy(ctx context.Context, v any) (*types.FrameworkOrderBy, error) {
if v == nil {
return nil, nil