Add compliance frameworks

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2026-03-03 08:56:39 +01:00
parent 4d882e37b0
commit c17c53e80f
36 changed files with 5303 additions and 90 deletions

View File

@@ -107,6 +107,21 @@ type AuditEdge @nda {
node: Audit!
}
type ComplianceFramework implements Node {
id: ID!
framework: Framework! @goField(forceResolver: true)
}
type ComplianceFrameworkConnection {
edges: [ComplianceFrameworkEdge!]!
pageInfo: PageInfo!
}
type ComplianceFrameworkEdge {
cursor: CursorKey!
node: ComplianceFramework!
}
enum CountryCode
@goModel(model: "go.probo.inc/probo/pkg/coredata.CountryCode") {
AD @goEnum(value: "go.probo.inc/probo/pkg/coredata.CountryCodeAD")
@@ -542,6 +557,13 @@ type TrustCenter implements Node {
last: Int
before: CursorKey
): TrustCenterFileConnection! @goField(forceResolver: true)
complianceFrameworks(
first: Int
after: CursorKey
last: Int
before: CursorKey
): ComplianceFrameworkConnection! @goField(forceResolver: true)
}
type TrustCenterAccess implements Node {

View File

@@ -37,6 +37,7 @@ type Config = graphql.Config[ResolverRoot, DirectiveRoot, ComplexityRoot]
type ResolverRoot interface {
Audit() AuditResolver
ComplianceFramework() ComplianceFrameworkResolver
Document() DocumentResolver
Framework() FrameworkResolver
Mutation() MutationResolver
@@ -77,6 +78,21 @@ type ComplexityRoot struct {
Node func(childComplexity int) int
}
ComplianceFramework struct {
Framework func(childComplexity int) int
ID func(childComplexity int) int
}
ComplianceFrameworkConnection struct {
Edges func(childComplexity int) int
PageInfo func(childComplexity int) int
}
ComplianceFrameworkEdge struct {
Cursor func(childComplexity int) int
Node func(childComplexity int) int
}
Document struct {
Access func(childComplexity int) int
DocumentType func(childComplexity int) int
@@ -216,6 +232,7 @@ type ComplexityRoot struct {
TrustCenter struct {
Active func(childComplexity int) int
Audits func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey) int
ComplianceFrameworks func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey) int
DarkLogoFileURL func(childComplexity int) int
Documents func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey) int
ID func(childComplexity int) int
@@ -302,6 +319,9 @@ type AuditResolver interface {
Framework(ctx context.Context, obj *types.Audit) (*types.Framework, error)
Report(ctx context.Context, obj *types.Audit) (*types.Report, error)
}
type ComplianceFrameworkResolver interface {
Framework(ctx context.Context, obj *types.ComplianceFramework) (*types.Framework, error)
}
type DocumentResolver interface {
IsUserAuthorized(ctx context.Context, obj *types.Document) (bool, error)
Access(ctx context.Context, obj *types.Document) (*types.DocumentAccess, error)
@@ -349,6 +369,7 @@ type TrustCenterResolver interface {
Vendors(ctx context.Context, obj *types.TrustCenter, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.VendorConnection, error)
References(ctx context.Context, obj *types.TrustCenter, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.TrustCenterReferenceConnection, error)
TrustCenterFiles(ctx context.Context, obj *types.TrustCenter, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.TrustCenterFileConnection, error)
ComplianceFrameworks(ctx context.Context, obj *types.TrustCenter, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.ComplianceFrameworkConnection, error)
}
type TrustCenterFileResolver interface {
IsUserAuthorized(ctx context.Context, obj *types.TrustCenterFile) (bool, error)
@@ -433,6 +454,45 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
return e.ComplexityRoot.AuditEdge.Node(childComplexity), true
case "ComplianceFramework.framework":
if e.ComplexityRoot.ComplianceFramework.Framework == nil {
break
}
return e.ComplexityRoot.ComplianceFramework.Framework(childComplexity), true
case "ComplianceFramework.id":
if e.ComplexityRoot.ComplianceFramework.ID == nil {
break
}
return e.ComplexityRoot.ComplianceFramework.ID(childComplexity), true
case "ComplianceFrameworkConnection.edges":
if e.ComplexityRoot.ComplianceFrameworkConnection.Edges == nil {
break
}
return e.ComplexityRoot.ComplianceFrameworkConnection.Edges(childComplexity), true
case "ComplianceFrameworkConnection.pageInfo":
if e.ComplexityRoot.ComplianceFrameworkConnection.PageInfo == nil {
break
}
return e.ComplexityRoot.ComplianceFrameworkConnection.PageInfo(childComplexity), true
case "ComplianceFrameworkEdge.cursor":
if e.ComplexityRoot.ComplianceFrameworkEdge.Cursor == nil {
break
}
return e.ComplexityRoot.ComplianceFrameworkEdge.Cursor(childComplexity), true
case "ComplianceFrameworkEdge.node":
if e.ComplexityRoot.ComplianceFrameworkEdge.Node == nil {
break
}
return e.ComplexityRoot.ComplianceFrameworkEdge.Node(childComplexity), true
case "Document.access":
if e.ComplexityRoot.Document.Access == nil {
break
@@ -948,6 +1008,17 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
}
return e.ComplexityRoot.TrustCenter.Audits(childComplexity, args["first"].(*int), args["after"].(*page.CursorKey), args["last"].(*int), args["before"].(*page.CursorKey)), true
case "TrustCenter.complianceFrameworks":
if e.ComplexityRoot.TrustCenter.ComplianceFrameworks == nil {
break
}
args, err := ec.field_TrustCenter_complianceFrameworks_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.TrustCenter.ComplianceFrameworks(childComplexity, args["first"].(*int), args["after"].(*page.CursorKey), args["last"].(*int), args["before"].(*page.CursorKey)), true
case "TrustCenter.darkLogoFileUrl":
if e.ComplexityRoot.TrustCenter.DarkLogoFileURL == nil {
break
@@ -1458,6 +1529,21 @@ type AuditEdge @nda {
node: Audit!
}
type ComplianceFramework implements Node {
id: ID!
framework: Framework! @goField(forceResolver: true)
}
type ComplianceFrameworkConnection {
edges: [ComplianceFrameworkEdge!]!
pageInfo: PageInfo!
}
type ComplianceFrameworkEdge {
cursor: CursorKey!
node: ComplianceFramework!
}
enum CountryCode
@goModel(model: "go.probo.inc/probo/pkg/coredata.CountryCode") {
AD @goEnum(value: "go.probo.inc/probo/pkg/coredata.CountryCodeAD")
@@ -1893,6 +1979,13 @@ type TrustCenter implements Node {
last: Int
before: CursorKey
): TrustCenterFileConnection! @goField(forceResolver: true)
complianceFrameworks(
first: Int
after: CursorKey
last: Int
before: CursorKey
): ComplianceFrameworkConnection! @goField(forceResolver: true)
}
type TrustCenterAccess implements Node {
@@ -2396,6 +2489,32 @@ func (ec *executionContext) field_TrustCenter_audits_args(ctx context.Context, r
return args, nil
}
func (ec *executionContext) field_TrustCenter_complianceFrameworks_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "first", ec.unmarshalOInt2ᚖint)
if err != nil {
return nil, err
}
args["first"] = arg0
arg1, err := graphql.ProcessArgField(ctx, rawArgs, "after", ec.unmarshalOCursorKey2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋpageᚐCursorKey)
if err != nil {
return nil, err
}
args["after"] = arg1
arg2, err := graphql.ProcessArgField(ctx, rawArgs, "last", ec.unmarshalOInt2ᚖint)
if err != nil {
return nil, err
}
args["last"] = arg2
arg3, err := graphql.ProcessArgField(ctx, rawArgs, "before", ec.unmarshalOCursorKey2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋpageᚐCursorKey)
if err != nil {
return nil, err
}
args["before"] = arg3
return args, nil
}
func (ec *executionContext) field_TrustCenter_documents_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
@@ -2929,6 +3048,212 @@ func (ec *executionContext) fieldContext_AuditEdge_node(_ context.Context, field
return fc, nil
}
func (ec *executionContext) _ComplianceFramework_id(ctx context.Context, field graphql.CollectedField, obj *types.ComplianceFramework) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_ComplianceFramework_id,
func(ctx context.Context) (any, error) {
return obj.ID, nil
},
nil,
ec.marshalNID2goᚗproboᚗincᚋproboᚋpkgᚋgidᚐGID,
true,
true,
)
}
func (ec *executionContext) fieldContext_ComplianceFramework_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "ComplianceFramework",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type ID does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _ComplianceFramework_framework(ctx context.Context, field graphql.CollectedField, obj *types.ComplianceFramework) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_ComplianceFramework_framework,
func(ctx context.Context) (any, error) {
return ec.Resolvers.ComplianceFramework().Framework(ctx, obj)
},
nil,
ec.marshalNFramework2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋtrustᚋv1ᚋtypesᚐFramework,
true,
true,
)
}
func (ec *executionContext) fieldContext_ComplianceFramework_framework(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "ComplianceFramework",
Field: field,
IsMethod: true,
IsResolver: true,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "id":
return ec.fieldContext_Framework_id(ctx, field)
case "name":
return ec.fieldContext_Framework_name(ctx, field)
case "lightLogoURL":
return ec.fieldContext_Framework_lightLogoURL(ctx, field)
case "darkLogoURL":
return ec.fieldContext_Framework_darkLogoURL(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Framework", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) _ComplianceFrameworkConnection_edges(ctx context.Context, field graphql.CollectedField, obj *types.ComplianceFrameworkConnection) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_ComplianceFrameworkConnection_edges,
func(ctx context.Context) (any, error) {
return obj.Edges, nil
},
nil,
ec.marshalNComplianceFrameworkEdge2ᚕᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋtrustᚋv1ᚋtypesᚐComplianceFrameworkEdgeᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext_ComplianceFrameworkConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "ComplianceFrameworkConnection",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "cursor":
return ec.fieldContext_ComplianceFrameworkEdge_cursor(ctx, field)
case "node":
return ec.fieldContext_ComplianceFrameworkEdge_node(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type ComplianceFrameworkEdge", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) _ComplianceFrameworkConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *types.ComplianceFrameworkConnection) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_ComplianceFrameworkConnection_pageInfo,
func(ctx context.Context) (any, error) {
return obj.PageInfo, nil
},
nil,
ec.marshalNPageInfo2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋtrustᚋv1ᚋtypesᚐPageInfo,
true,
true,
)
}
func (ec *executionContext) fieldContext_ComplianceFrameworkConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "ComplianceFrameworkConnection",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "hasNextPage":
return ec.fieldContext_PageInfo_hasNextPage(ctx, field)
case "hasPreviousPage":
return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field)
case "startCursor":
return ec.fieldContext_PageInfo_startCursor(ctx, field)
case "endCursor":
return ec.fieldContext_PageInfo_endCursor(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) _ComplianceFrameworkEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *types.ComplianceFrameworkEdge) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_ComplianceFrameworkEdge_cursor,
func(ctx context.Context) (any, error) {
return obj.Cursor, nil
},
nil,
ec.marshalNCursorKey2goᚗproboᚗincᚋproboᚋpkgᚋpageᚐCursorKey,
true,
true,
)
}
func (ec *executionContext) fieldContext_ComplianceFrameworkEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "ComplianceFrameworkEdge",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type CursorKey does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _ComplianceFrameworkEdge_node(ctx context.Context, field graphql.CollectedField, obj *types.ComplianceFrameworkEdge) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_ComplianceFrameworkEdge_node,
func(ctx context.Context) (any, error) {
return obj.Node, nil
},
nil,
ec.marshalNComplianceFramework2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋtrustᚋv1ᚋtypesᚐComplianceFramework,
true,
true,
)
}
func (ec *executionContext) fieldContext_ComplianceFrameworkEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "ComplianceFrameworkEdge",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "id":
return ec.fieldContext_ComplianceFramework_id(ctx, field)
case "framework":
return ec.fieldContext_ComplianceFramework_framework(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type ComplianceFramework", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) _Document_id(ctx context.Context, field graphql.CollectedField, obj *types.Document) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
@@ -5203,6 +5528,8 @@ func (ec *executionContext) fieldContext_Query_currentTrustCenter(_ context.Cont
return ec.fieldContext_TrustCenter_references(ctx, field)
case "trustCenterFiles":
return ec.fieldContext_TrustCenter_trustCenterFiles(ctx, field)
case "complianceFrameworks":
return ec.fieldContext_TrustCenter_complianceFrameworks(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type TrustCenter", field.Name)
},
@@ -6228,6 +6555,53 @@ func (ec *executionContext) fieldContext_TrustCenter_trustCenterFiles(ctx contex
return fc, nil
}
func (ec *executionContext) _TrustCenter_complianceFrameworks(ctx context.Context, field graphql.CollectedField, obj *types.TrustCenter) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_TrustCenter_complianceFrameworks,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.TrustCenter().ComplianceFrameworks(ctx, obj, fc.Args["first"].(*int), fc.Args["after"].(*page.CursorKey), fc.Args["last"].(*int), fc.Args["before"].(*page.CursorKey))
},
nil,
ec.marshalNComplianceFrameworkConnection2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋtrustᚋv1ᚋtypesᚐComplianceFrameworkConnection,
true,
true,
)
}
func (ec *executionContext) fieldContext_TrustCenter_complianceFrameworks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "TrustCenter",
Field: field,
IsMethod: true,
IsResolver: true,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "edges":
return ec.fieldContext_ComplianceFrameworkConnection_edges(ctx, field)
case "pageInfo":
return ec.fieldContext_ComplianceFrameworkConnection_pageInfo(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type ComplianceFrameworkConnection", field.Name)
},
}
defer func() {
if r := recover(); r != nil {
err = ec.Recover(ctx, r)
ec.Error(ctx, err)
}
}()
ctx = graphql.WithFieldContext(ctx, fc)
if fc.Args, err = ec.field_TrustCenter_complianceFrameworks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _TrustCenterAccess_id(ctx context.Context, field graphql.CollectedField, obj *types.TrustCenterAccess) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
@@ -9263,6 +9637,13 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj
return graphql.Null
}
return ec._Document(ctx, sel, obj)
case types.ComplianceFramework:
return ec._ComplianceFramework(ctx, sel, &obj)
case *types.ComplianceFramework:
if obj == nil {
return graphql.Null
}
return ec._ComplianceFramework(ctx, sel, obj)
case types.Audit:
return ec._Audit(ctx, sel, &obj)
case *types.Audit:
@@ -9520,6 +9901,169 @@ func (ec *executionContext) _AuditEdge(ctx context.Context, sel ast.SelectionSet
return out
}
var complianceFrameworkImplementors = []string{"ComplianceFramework", "Node"}
func (ec *executionContext) _ComplianceFramework(ctx context.Context, sel ast.SelectionSet, obj *types.ComplianceFramework) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, complianceFrameworkImplementors)
out := graphql.NewFieldSet(fields)
deferred := make(map[string]*graphql.FieldSet)
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("ComplianceFramework")
case "id":
out.Values[i] = ec._ComplianceFramework_id(ctx, field, obj)
if out.Values[i] == graphql.Null {
atomic.AddUint32(&out.Invalids, 1)
}
case "framework":
field := field
innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._ComplianceFramework_framework(ctx, field, obj)
if res == graphql.Null {
atomic.AddUint32(&fs.Invalids, 1)
}
return res
}
if field.Deferrable != nil {
dfs, ok := deferred[field.Deferrable.Label]
di := 0
if ok {
dfs.AddField(field)
di = len(dfs.Values) - 1
} else {
dfs = graphql.NewFieldSet([]graphql.CollectedField{field})
deferred[field.Deferrable.Label] = dfs
}
dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler {
return innerFunc(ctx, dfs)
})
// don't run the out.Concurrently() call below
out.Values[i] = graphql.Null
continue
}
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch(ctx)
if out.Invalids > 0 {
return graphql.Null
}
atomic.AddInt32(&ec.Deferred, int32(len(deferred)))
for label, dfs := range deferred {
ec.ProcessDeferredGroup(graphql.DeferredGroup{
Label: label,
Path: graphql.GetPath(ctx),
FieldSet: dfs,
Context: ctx,
})
}
return out
}
var complianceFrameworkConnectionImplementors = []string{"ComplianceFrameworkConnection"}
func (ec *executionContext) _ComplianceFrameworkConnection(ctx context.Context, sel ast.SelectionSet, obj *types.ComplianceFrameworkConnection) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, complianceFrameworkConnectionImplementors)
out := graphql.NewFieldSet(fields)
deferred := make(map[string]*graphql.FieldSet)
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("ComplianceFrameworkConnection")
case "edges":
out.Values[i] = ec._ComplianceFrameworkConnection_edges(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "pageInfo":
out.Values[i] = ec._ComplianceFrameworkConnection_pageInfo(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch(ctx)
if out.Invalids > 0 {
return graphql.Null
}
atomic.AddInt32(&ec.Deferred, int32(len(deferred)))
for label, dfs := range deferred {
ec.ProcessDeferredGroup(graphql.DeferredGroup{
Label: label,
Path: graphql.GetPath(ctx),
FieldSet: dfs,
Context: ctx,
})
}
return out
}
var complianceFrameworkEdgeImplementors = []string{"ComplianceFrameworkEdge"}
func (ec *executionContext) _ComplianceFrameworkEdge(ctx context.Context, sel ast.SelectionSet, obj *types.ComplianceFrameworkEdge) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, complianceFrameworkEdgeImplementors)
out := graphql.NewFieldSet(fields)
deferred := make(map[string]*graphql.FieldSet)
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("ComplianceFrameworkEdge")
case "cursor":
out.Values[i] = ec._ComplianceFrameworkEdge_cursor(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "node":
out.Values[i] = ec._ComplianceFrameworkEdge_node(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch(ctx)
if out.Invalids > 0 {
return graphql.Null
}
atomic.AddInt32(&ec.Deferred, int32(len(deferred)))
for label, dfs := range deferred {
ec.ProcessDeferredGroup(graphql.DeferredGroup{
Label: label,
Path: graphql.GetPath(ctx),
FieldSet: dfs,
Context: ctx,
})
}
return out
}
var documentImplementors = []string{"Document", "Node"}
func (ec *executionContext) _Document(ctx context.Context, sel ast.SelectionSet, obj *types.Document) graphql.Marshaler {
@@ -11265,6 +11809,42 @@ func (ec *executionContext) _TrustCenter(ctx context.Context, sel ast.SelectionS
continue
}
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
case "complianceFrameworks":
field := field
innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._TrustCenter_complianceFrameworks(ctx, field, obj)
if res == graphql.Null {
atomic.AddUint32(&fs.Invalids, 1)
}
return res
}
if field.Deferrable != nil {
dfs, ok := deferred[field.Deferrable.Label]
di := 0
if ok {
dfs.AddField(field)
di = len(dfs.Values) - 1
} else {
dfs = graphql.NewFieldSet([]graphql.CollectedField{field})
deferred[field.Deferrable.Label] = dfs
}
dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler {
return innerFunc(ctx, dfs)
})
// don't run the out.Concurrently() call below
out.Values[i] = graphql.Null
continue
}
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
default:
panic("unknown field " + strconv.Quote(field.Name))
@@ -12355,6 +12935,56 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se
return res
}
func (ec *executionContext) marshalNComplianceFramework2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋtrustᚋv1ᚋtypesᚐComplianceFramework(ctx context.Context, sel ast.SelectionSet, v *types.ComplianceFramework) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return ec._ComplianceFramework(ctx, sel, v)
}
func (ec *executionContext) marshalNComplianceFrameworkConnection2goᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋtrustᚋv1ᚋtypesᚐComplianceFrameworkConnection(ctx context.Context, sel ast.SelectionSet, v types.ComplianceFrameworkConnection) graphql.Marshaler {
return ec._ComplianceFrameworkConnection(ctx, sel, &v)
}
func (ec *executionContext) marshalNComplianceFrameworkConnection2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋtrustᚋv1ᚋtypesᚐComplianceFrameworkConnection(ctx context.Context, sel ast.SelectionSet, v *types.ComplianceFrameworkConnection) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return ec._ComplianceFrameworkConnection(ctx, sel, v)
}
func (ec *executionContext) marshalNComplianceFrameworkEdge2ᚕᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋtrustᚋv1ᚋtypesᚐComplianceFrameworkEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*types.ComplianceFrameworkEdge) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalNComplianceFrameworkEdge2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋtrustᚋv1ᚋtypesᚐComplianceFrameworkEdge(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalNComplianceFrameworkEdge2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋtrustᚋv1ᚋtypesᚐComplianceFrameworkEdge(ctx context.Context, sel ast.SelectionSet, v *types.ComplianceFrameworkEdge) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return ec._ComplianceFrameworkEdge(ctx, sel, v)
}
func (ec *executionContext) unmarshalNCountryCode2goᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐCountryCode(ctx context.Context, v any) (coredata.CountryCode, error) {
tmp, err := graphql.UnmarshalString(v)
res := unmarshalNCountryCode2goᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐCountryCode[tmp]

View File

@@ -16,6 +16,7 @@ package types
import (
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/page"
)
func NewFramework(f *coredata.Framework) *Framework {
@@ -24,3 +25,31 @@ func NewFramework(f *coredata.Framework) *Framework {
Name: f.Name,
}
}
func NewComplianceFramework(cf *coredata.ComplianceFramework) *ComplianceFramework {
return &ComplianceFramework{
ID: cf.ID,
FrameworkID: cf.FrameworkID,
}
}
func NewComplianceFrameworkEdge(cf *coredata.ComplianceFramework) *ComplianceFrameworkEdge {
return &ComplianceFrameworkEdge{
Cursor: cf.CursorKey(coredata.ComplianceFrameworkOrderFieldRank),
Node: NewComplianceFramework(cf),
}
}
func NewComplianceFrameworkConnection(
p *page.Page[*coredata.ComplianceFramework, coredata.ComplianceFrameworkOrderField],
) *ComplianceFrameworkConnection {
edges := make([]*ComplianceFrameworkEdge, len(p.Data))
for i, cf := range p.Data {
edges[i] = NewComplianceFrameworkEdge(cf)
}
return &ComplianceFrameworkConnection{
Edges: edges,
PageInfo: NewPageInfo(p),
}
}

View File

@@ -45,6 +45,26 @@ type AuditEdge struct {
Node *Audit `json:"node"`
}
type ComplianceFramework struct {
ID gid.GID `json:"id"`
// FrameworkID is a non-schema field used by the Framework resolver to avoid an extra DB lookup.
FrameworkID gid.GID `json:"-"`
Framework *Framework `json:"framework"`
}
func (ComplianceFramework) IsNode() {}
func (this ComplianceFramework) GetID() gid.GID { return this.ID }
type ComplianceFrameworkConnection struct {
Edges []*ComplianceFrameworkEdge `json:"edges"`
PageInfo *PageInfo `json:"pageInfo"`
}
type ComplianceFrameworkEdge struct {
Cursor page.CursorKey `json:"cursor"`
Node *ComplianceFramework `json:"node"`
}
type Document struct {
ID gid.GID `json:"id"`
Title string `json:"title"`
@@ -235,6 +255,7 @@ type TrustCenter struct {
Vendors *VendorConnection `json:"vendors"`
References *TrustCenterReferenceConnection `json:"references"`
TrustCenterFiles *TrustCenterFileConnection `json:"trustCenterFiles"`
ComplianceFrameworks *ComplianceFrameworkConnection `json:"complianceFrameworks"`
}
func (TrustCenter) IsNode() {}

View File

@@ -71,6 +71,19 @@ func (r *auditResolver) Report(ctx context.Context, obj *types.Audit) (*types.Re
return types.NewReport(report), nil
}
// Framework is the resolver for the framework field on ComplianceFramework.
func (r *complianceFrameworkResolver) Framework(ctx context.Context, obj *types.ComplianceFramework) (*types.Framework, error) {
trustService := r.TrustService(ctx, obj.ID.TenantID())
framework, err := trustService.Frameworks.Get(ctx, obj.FrameworkID)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot load framework", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return types.NewFramework(framework), nil
}
// IsUserAuthorized is the resolver for the isUserAuthorized field.
func (r *documentResolver) IsUserAuthorized(ctx context.Context, obj *types.Document) (bool, error) {
trustService := r.TrustService(ctx, obj.ID.TenantID())
@@ -1014,6 +1027,25 @@ func (r *trustCenterResolver) TrustCenterFiles(ctx context.Context, obj *types.T
return types.NewTrustCenterFileConnection(trustCenterFilePage), nil
}
// ComplianceFrameworks is the resolver for the complianceFrameworks field.
func (r *trustCenterResolver) ComplianceFrameworks(ctx context.Context, obj *types.TrustCenter, first *int, after *page.CursorKey, last *int, before *page.CursorKey) (*types.ComplianceFrameworkConnection, error) {
trustService := r.TrustService(ctx, obj.ID.TenantID())
pageOrderBy := page.OrderBy[coredata.ComplianceFrameworkOrderField]{
Field: coredata.ComplianceFrameworkOrderFieldRank,
Direction: page.OrderDirectionAsc,
}
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
cfPage, err := trustService.ComplianceFrameworks.ListByTrustCenterID(ctx, obj.ID, cursor)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot list compliance frameworks", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return types.NewComplianceFrameworkConnection(cfPage), nil
}
// IsUserAuthorized is the resolver for the isUserAuthorized field.
func (r *trustCenterFileResolver) IsUserAuthorized(ctx context.Context, obj *types.TrustCenterFile) (bool, error) {
trustService := r.TrustService(ctx, obj.ID.TenantID())
@@ -1124,6 +1156,11 @@ func (r *vendorConnectionResolver) TotalCount(ctx context.Context, obj *types.Ve
// Audit returns schema.AuditResolver implementation.
func (r *Resolver) Audit() schema.AuditResolver { return &auditResolver{r} }
// ComplianceFramework returns schema.ComplianceFrameworkResolver implementation.
func (r *Resolver) ComplianceFramework() schema.ComplianceFrameworkResolver {
return &complianceFrameworkResolver{r}
}
// Document returns schema.DocumentResolver implementation.
func (r *Resolver) Document() schema.DocumentResolver { return &documentResolver{r} }
@@ -1166,6 +1203,7 @@ func (r *Resolver) VendorConnection() schema.VendorConnectionResolver {
}
type auditResolver struct{ *Resolver }
type complianceFrameworkResolver struct{ *Resolver }
type documentResolver struct{ *Resolver }
type frameworkResolver struct{ *Resolver }
type mutationResolver struct{ *Resolver }