Add multi-approver support

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-02-13 12:49:22 +01:00
committed by Sacha Al Himdani
parent 3d8c7c4dd6
commit 93c7b0c2dc
41 changed files with 1721 additions and 461 deletions

View File

@@ -2208,7 +2208,13 @@ type Document implements Node {
classification: DocumentClassification!
currentPublishedVersion: Int
trustCenterVisibility: TrustCenterVisibility!
approver: Profile! @goField(forceResolver: true)
approvers(
first: Int
after: CursorKey
last: Int
before: CursorKey
orderBy: ProfileOrder
): ProfileConnection! @goField(forceResolver: true)
organization: Organization! @goField(forceResolver: true)
versions(
@@ -4018,7 +4024,7 @@ input CreateDocumentInput {
organizationId: ID!
title: String!
content: String!
approverId: ID!
approverIds: [ID!]!
documentType: DocumentType!
classification: DocumentClassification!
trustCenterVisibility: TrustCenterVisibility
@@ -4028,7 +4034,7 @@ input UpdateDocumentInput {
id: ID!
title: String
content: String
approverId: ID
approverIds: [ID!]
documentType: DocumentType
classification: DocumentClassification
trustCenterVisibility: TrustCenterVisibility
@@ -4862,7 +4868,13 @@ type DocumentVersion implements Node {
changelog: String!
title: String!
classification: DocumentClassification!
approver: Profile! @goField(forceResolver: true)
approvers(
first: Int
after: CursorKey
last: Int
before: CursorKey
orderBy: ProfileOrder
): ProfileConnection! @goField(forceResolver: true)
signatures(
first: Int

View File

@@ -702,7 +702,7 @@ type ComplexityRoot struct {
}
Document struct {
Approver func(childComplexity int) int
Approvers func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ProfileOrderBy) int
Classification func(childComplexity int) int
Controls func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy, filter *types.ControlFilter) int
CreatedAt func(childComplexity int) int
@@ -730,7 +730,7 @@ type ComplexityRoot struct {
}
DocumentVersion struct {
Approver func(childComplexity int) int
Approvers func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ProfileOrderBy) int
Changelog func(childComplexity int) int
Classification func(childComplexity int) int
Content func(childComplexity int) int
@@ -2058,7 +2058,7 @@ type DatumConnectionResolver interface {
TotalCount(ctx context.Context, obj *types.DatumConnection) (int, error)
}
type DocumentResolver interface {
Approver(ctx context.Context, obj *types.Document) (*types.Profile, error)
Approvers(ctx context.Context, obj *types.Document, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ProfileOrderBy) (*types.ProfileConnection, error)
Organization(ctx context.Context, obj *types.Document) (*types.Organization, error)
Versions(ctx context.Context, obj *types.Document, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DocumentVersionOrderBy, filter *types.DocumentVersionFilter) (*types.DocumentVersionConnection, error)
Controls(ctx context.Context, obj *types.Document, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy, filter *types.ControlFilter) (*types.ControlConnection, error)
@@ -2071,7 +2071,7 @@ type DocumentConnectionResolver interface {
type DocumentVersionResolver interface {
Document(ctx context.Context, obj *types.DocumentVersion) (*types.Document, error)
Approver(ctx context.Context, obj *types.DocumentVersion) (*types.Profile, error)
Approvers(ctx context.Context, obj *types.DocumentVersion, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ProfileOrderBy) (*types.ProfileConnection, error)
Signatures(ctx context.Context, obj *types.DocumentVersion, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.DocumentVersionSignatureOrder, filter *types.DocumentVersionSignatureFilter) (*types.DocumentVersionSignatureConnection, error)
Signed(ctx context.Context, obj *types.DocumentVersion) (bool, error)
@@ -4208,12 +4208,17 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
return e.complexity.DeleteWebhookSubscriptionPayload.DeletedWebhookSubscriptionID(childComplexity), true
case "Document.approver":
if e.complexity.Document.Approver == nil {
case "Document.approvers":
if e.complexity.Document.Approvers == nil {
break
}
return e.complexity.Document.Approver(childComplexity), true
args, err := ec.field_Document_approvers_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.complexity.Document.Approvers(childComplexity, args["first"].(*int), args["after"].(*page.CursorKey), args["last"].(*int), args["before"].(*page.CursorKey), args["orderBy"].(*types.ProfileOrderBy)), true
case "Document.classification":
if e.complexity.Document.Classification == nil {
break
@@ -4340,12 +4345,17 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
return e.complexity.DocumentEdge.Node(childComplexity), true
case "DocumentVersion.approver":
if e.complexity.DocumentVersion.Approver == nil {
case "DocumentVersion.approvers":
if e.complexity.DocumentVersion.Approvers == nil {
break
}
return e.complexity.DocumentVersion.Approver(childComplexity), true
args, err := ec.field_DocumentVersion_approvers_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.complexity.DocumentVersion.Approvers(childComplexity, args["first"].(*int), args["after"].(*page.CursorKey), args["last"].(*int), args["before"].(*page.CursorKey), args["orderBy"].(*types.ProfileOrderBy)), true
case "DocumentVersion.changelog":
if e.complexity.DocumentVersion.Changelog == nil {
break
@@ -12795,7 +12805,13 @@ type Document implements Node {
classification: DocumentClassification!
currentPublishedVersion: Int
trustCenterVisibility: TrustCenterVisibility!
approver: Profile! @goField(forceResolver: true)
approvers(
first: Int
after: CursorKey
last: Int
before: CursorKey
orderBy: ProfileOrder
): ProfileConnection! @goField(forceResolver: true)
organization: Organization! @goField(forceResolver: true)
versions(
@@ -14605,7 +14621,7 @@ input CreateDocumentInput {
organizationId: ID!
title: String!
content: String!
approverId: ID!
approverIds: [ID!]!
documentType: DocumentType!
classification: DocumentClassification!
trustCenterVisibility: TrustCenterVisibility
@@ -14615,7 +14631,7 @@ input UpdateDocumentInput {
id: ID!
title: String
content: String
approverId: ID
approverIds: [ID!]
documentType: DocumentType
classification: DocumentClassification
trustCenterVisibility: TrustCenterVisibility
@@ -15449,7 +15465,13 @@ type DocumentVersion implements Node {
changelog: String!
title: String!
classification: DocumentClassification!
approver: Profile! @goField(forceResolver: true)
approvers(
first: Int
after: CursorKey
last: Int
before: CursorKey
orderBy: ProfileOrder
): ProfileConnection! @goField(forceResolver: true)
signatures(
first: Int
@@ -16362,6 +16384,37 @@ func (ec *executionContext) field_DocumentVersionSignature_permission_args(ctx c
return args, nil
}
func (ec *executionContext) field_DocumentVersion_approvers_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
arg4, err := graphql.ProcessArgField(ctx, rawArgs, "orderBy", ec.unmarshalOProfileOrder2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐProfileOrderBy)
if err != nil {
return nil, err
}
args["orderBy"] = arg4
return args, nil
}
func (ec *executionContext) field_DocumentVersion_permission_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
@@ -16409,6 +16462,37 @@ func (ec *executionContext) field_DocumentVersion_signatures_args(ctx context.Co
return args, nil
}
func (ec *executionContext) field_Document_approvers_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
arg4, err := graphql.ProcessArgField(ctx, rawArgs, "orderBy", ec.unmarshalOProfileOrder2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐProfileOrderBy)
if err != nil {
return nil, err
}
args["orderBy"] = arg4
return args, nil
}
func (ec *executionContext) field_Document_controls_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
@@ -29115,23 +29199,24 @@ func (ec *executionContext) fieldContext_Document_trustCenterVisibility(_ contex
return fc, nil
}
func (ec *executionContext) _Document_approver(ctx context.Context, field graphql.CollectedField, obj *types.Document) (ret graphql.Marshaler) {
func (ec *executionContext) _Document_approvers(ctx context.Context, field graphql.CollectedField, obj *types.Document) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Document_approver,
ec.fieldContext_Document_approvers,
func(ctx context.Context) (any, error) {
return ec.resolvers.Document().Approver(ctx, obj)
fc := graphql.GetFieldContext(ctx)
return ec.resolvers.Document().Approvers(ctx, obj, fc.Args["first"].(*int), fc.Args["after"].(*page.CursorKey), fc.Args["last"].(*int), fc.Args["before"].(*page.CursorKey), fc.Args["orderBy"].(*types.ProfileOrderBy))
},
nil,
ec.marshalNProfile2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐProfile,
ec.marshalNProfileConnection2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐProfileConnection,
true,
true,
)
}
func (ec *executionContext) fieldContext_Document_approver(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
func (ec *executionContext) fieldContext_Document_approvers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Document",
Field: field,
@@ -29139,32 +29224,27 @@ func (ec *executionContext) fieldContext_Document_approver(_ context.Context, fi
IsResolver: true,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "id":
return ec.fieldContext_Profile_id(ctx, field)
case "fullName":
return ec.fieldContext_Profile_fullName(ctx, field)
case "emailAddress":
return ec.fieldContext_Profile_emailAddress(ctx, field)
case "additionalEmailAddresses":
return ec.fieldContext_Profile_additionalEmailAddresses(ctx, field)
case "kind":
return ec.fieldContext_Profile_kind(ctx, field)
case "position":
return ec.fieldContext_Profile_position(ctx, field)
case "contractStartDate":
return ec.fieldContext_Profile_contractStartDate(ctx, field)
case "contractEndDate":
return ec.fieldContext_Profile_contractEndDate(ctx, field)
case "createdAt":
return ec.fieldContext_Profile_createdAt(ctx, field)
case "updatedAt":
return ec.fieldContext_Profile_updatedAt(ctx, field)
case "permission":
return ec.fieldContext_Profile_permission(ctx, field)
case "totalCount":
return ec.fieldContext_ProfileConnection_totalCount(ctx, field)
case "edges":
return ec.fieldContext_ProfileConnection_edges(ctx, field)
case "pageInfo":
return ec.fieldContext_ProfileConnection_pageInfo(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Profile", field.Name)
return nil, fmt.Errorf("no field named %q was found under type ProfileConnection", 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_Document_approvers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
@@ -29642,8 +29722,8 @@ func (ec *executionContext) fieldContext_DocumentEdge_node(_ context.Context, fi
return ec.fieldContext_Document_currentPublishedVersion(ctx, field)
case "trustCenterVisibility":
return ec.fieldContext_Document_trustCenterVisibility(ctx, field)
case "approver":
return ec.fieldContext_Document_approver(ctx, field)
case "approvers":
return ec.fieldContext_Document_approvers(ctx, field)
case "organization":
return ec.fieldContext_Document_organization(ctx, field)
case "versions":
@@ -29730,8 +29810,8 @@ func (ec *executionContext) fieldContext_DocumentVersion_document(_ context.Cont
return ec.fieldContext_Document_currentPublishedVersion(ctx, field)
case "trustCenterVisibility":
return ec.fieldContext_Document_trustCenterVisibility(ctx, field)
case "approver":
return ec.fieldContext_Document_approver(ctx, field)
case "approvers":
return ec.fieldContext_Document_approvers(ctx, field)
case "organization":
return ec.fieldContext_Document_organization(ctx, field)
case "versions":
@@ -29925,23 +30005,24 @@ func (ec *executionContext) fieldContext_DocumentVersion_classification(_ contex
return fc, nil
}
func (ec *executionContext) _DocumentVersion_approver(ctx context.Context, field graphql.CollectedField, obj *types.DocumentVersion) (ret graphql.Marshaler) {
func (ec *executionContext) _DocumentVersion_approvers(ctx context.Context, field graphql.CollectedField, obj *types.DocumentVersion) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_DocumentVersion_approver,
ec.fieldContext_DocumentVersion_approvers,
func(ctx context.Context) (any, error) {
return ec.resolvers.DocumentVersion().Approver(ctx, obj)
fc := graphql.GetFieldContext(ctx)
return ec.resolvers.DocumentVersion().Approvers(ctx, obj, fc.Args["first"].(*int), fc.Args["after"].(*page.CursorKey), fc.Args["last"].(*int), fc.Args["before"].(*page.CursorKey), fc.Args["orderBy"].(*types.ProfileOrderBy))
},
nil,
ec.marshalNProfile2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐProfile,
ec.marshalNProfileConnection2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐProfileConnection,
true,
true,
)
}
func (ec *executionContext) fieldContext_DocumentVersion_approver(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
func (ec *executionContext) fieldContext_DocumentVersion_approvers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "DocumentVersion",
Field: field,
@@ -29949,32 +30030,27 @@ func (ec *executionContext) fieldContext_DocumentVersion_approver(_ context.Cont
IsResolver: true,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "id":
return ec.fieldContext_Profile_id(ctx, field)
case "fullName":
return ec.fieldContext_Profile_fullName(ctx, field)
case "emailAddress":
return ec.fieldContext_Profile_emailAddress(ctx, field)
case "additionalEmailAddresses":
return ec.fieldContext_Profile_additionalEmailAddresses(ctx, field)
case "kind":
return ec.fieldContext_Profile_kind(ctx, field)
case "position":
return ec.fieldContext_Profile_position(ctx, field)
case "contractStartDate":
return ec.fieldContext_Profile_contractStartDate(ctx, field)
case "contractEndDate":
return ec.fieldContext_Profile_contractEndDate(ctx, field)
case "createdAt":
return ec.fieldContext_Profile_createdAt(ctx, field)
case "updatedAt":
return ec.fieldContext_Profile_updatedAt(ctx, field)
case "permission":
return ec.fieldContext_Profile_permission(ctx, field)
case "totalCount":
return ec.fieldContext_ProfileConnection_totalCount(ctx, field)
case "edges":
return ec.fieldContext_ProfileConnection_edges(ctx, field)
case "pageInfo":
return ec.fieldContext_ProfileConnection_pageInfo(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Profile", field.Name)
return nil, fmt.Errorf("no field named %q was found under type ProfileConnection", 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_DocumentVersion_approvers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
@@ -30356,8 +30432,8 @@ func (ec *executionContext) fieldContext_DocumentVersionEdge_node(_ context.Cont
return ec.fieldContext_DocumentVersion_title(ctx, field)
case "classification":
return ec.fieldContext_DocumentVersion_classification(ctx, field)
case "approver":
return ec.fieldContext_DocumentVersion_approver(ctx, field)
case "approvers":
return ec.fieldContext_DocumentVersion_approvers(ctx, field)
case "signatures":
return ec.fieldContext_DocumentVersion_signatures(ctx, field)
case "signed":
@@ -30446,8 +30522,8 @@ func (ec *executionContext) fieldContext_DocumentVersionSignature_documentVersio
return ec.fieldContext_DocumentVersion_title(ctx, field)
case "classification":
return ec.fieldContext_DocumentVersion_classification(ctx, field)
case "approver":
return ec.fieldContext_DocumentVersion_approver(ctx, field)
case "approvers":
return ec.fieldContext_DocumentVersion_approvers(ctx, field)
case "signatures":
return ec.fieldContext_DocumentVersion_signatures(ctx, field)
case "signed":
@@ -45461,8 +45537,8 @@ func (ec *executionContext) fieldContext_PublishDocumentVersionPayload_documentV
return ec.fieldContext_DocumentVersion_title(ctx, field)
case "classification":
return ec.fieldContext_DocumentVersion_classification(ctx, field)
case "approver":
return ec.fieldContext_DocumentVersion_approver(ctx, field)
case "approvers":
return ec.fieldContext_DocumentVersion_approvers(ctx, field)
case "signatures":
return ec.fieldContext_DocumentVersion_signatures(ctx, field)
case "signed":
@@ -45520,8 +45596,8 @@ func (ec *executionContext) fieldContext_PublishDocumentVersionPayload_document(
return ec.fieldContext_Document_currentPublishedVersion(ctx, field)
case "trustCenterVisibility":
return ec.fieldContext_Document_trustCenterVisibility(ctx, field)
case "approver":
return ec.fieldContext_Document_approver(ctx, field)
case "approvers":
return ec.fieldContext_Document_approvers(ctx, field)
case "organization":
return ec.fieldContext_Document_organization(ctx, field)
case "versions":
@@ -52250,8 +52326,8 @@ func (ec *executionContext) fieldContext_TrustCenterDocumentAccess_document(_ co
return ec.fieldContext_Document_currentPublishedVersion(ctx, field)
case "trustCenterVisibility":
return ec.fieldContext_Document_trustCenterVisibility(ctx, field)
case "approver":
return ec.fieldContext_Document_approver(ctx, field)
case "approvers":
return ec.fieldContext_Document_approvers(ctx, field)
case "organization":
return ec.fieldContext_Document_organization(ctx, field)
case "versions":
@@ -54047,8 +54123,8 @@ func (ec *executionContext) fieldContext_UpdateDocumentPayload_document(_ contex
return ec.fieldContext_Document_currentPublishedVersion(ctx, field)
case "trustCenterVisibility":
return ec.fieldContext_Document_trustCenterVisibility(ctx, field)
case "approver":
return ec.fieldContext_Document_approver(ctx, field)
case "approvers":
return ec.fieldContext_Document_approvers(ctx, field)
case "organization":
return ec.fieldContext_Document_organization(ctx, field)
case "versions":
@@ -54108,8 +54184,8 @@ func (ec *executionContext) fieldContext_UpdateDocumentVersionPayload_documentVe
return ec.fieldContext_DocumentVersion_title(ctx, field)
case "classification":
return ec.fieldContext_DocumentVersion_classification(ctx, field)
case "approver":
return ec.fieldContext_DocumentVersion_approver(ctx, field)
case "approvers":
return ec.fieldContext_DocumentVersion_approvers(ctx, field)
case "signatures":
return ec.fieldContext_DocumentVersion_signatures(ctx, field)
case "signed":
@@ -63387,7 +63463,7 @@ func (ec *executionContext) unmarshalInputCreateDocumentInput(ctx context.Contex
asMap[k] = v
}
fieldsInOrder := [...]string{"organizationId", "title", "content", "approverId", "documentType", "classification", "trustCenterVisibility"}
fieldsInOrder := [...]string{"organizationId", "title", "content", "approverIds", "documentType", "classification", "trustCenterVisibility"}
for _, k := range fieldsInOrder {
v, ok := asMap[k]
if !ok {
@@ -63415,13 +63491,13 @@ func (ec *executionContext) unmarshalInputCreateDocumentInput(ctx context.Contex
return it, err
}
it.Content = data
case "approverId":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("approverId"))
data, err := ec.unmarshalNID2goᚗproboᚗincᚋproboᚋpkgᚋgidᚐGID(ctx, v)
case "approverIds":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("approverIds"))
data, err := ec.unmarshalNID2ᚕgoᚗproboᚗincᚋproboᚋpkgᚋgidᚐGIDᚄ(ctx, v)
if err != nil {
return it, err
}
it.ApproverID = data
it.ApproverIds = data
case "documentType":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("documentType"))
data, err := ec.unmarshalNDocumentType2goᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐDocumentType(ctx, v)
@@ -68341,7 +68417,7 @@ func (ec *executionContext) unmarshalInputUpdateDocumentInput(ctx context.Contex
asMap[k] = v
}
fieldsInOrder := [...]string{"id", "title", "content", "approverId", "documentType", "classification", "trustCenterVisibility"}
fieldsInOrder := [...]string{"id", "title", "content", "approverIds", "documentType", "classification", "trustCenterVisibility"}
for _, k := range fieldsInOrder {
v, ok := asMap[k]
if !ok {
@@ -68369,13 +68445,13 @@ func (ec *executionContext) unmarshalInputUpdateDocumentInput(ctx context.Contex
return it, err
}
it.Content = data
case "approverId":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("approverId"))
data, err := ec.unmarshalOID2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋgidᚐGID(ctx, v)
case "approverIds":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("approverIds"))
data, err := ec.unmarshalOID2ᚕgoᚗproboᚗincᚋproboᚋpkgᚋgidᚐGIDᚄ(ctx, v)
if err != nil {
return it, err
}
it.ApproverID = data
it.ApproverIds = data
case "documentType":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("documentType"))
data, err := ec.unmarshalODocumentType2ᚖgoᚗproboᚗincᚋproboᚋpkgᚋcoredataᚐDocumentType(ctx, v)
@@ -77056,7 +77132,7 @@ func (ec *executionContext) _Document(ctx context.Context, sel ast.SelectionSet,
if out.Values[i] == graphql.Null {
atomic.AddUint32(&out.Invalids, 1)
}
case "approver":
case "approvers":
field := field
innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
@@ -77065,7 +77141,7 @@ func (ec *executionContext) _Document(ctx context.Context, sel ast.SelectionSet,
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._Document_approver(ctx, field, obj)
res = ec._Document_approvers(ctx, field, obj)
if res == graphql.Null {
atomic.AddUint32(&fs.Invalids, 1)
}
@@ -77475,7 +77551,7 @@ func (ec *executionContext) _DocumentVersion(ctx context.Context, sel ast.Select
if out.Values[i] == graphql.Null {
atomic.AddUint32(&out.Invalids, 1)
}
case "approver":
case "approvers":
field := field
innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
@@ -77484,7 +77560,7 @@ func (ec *executionContext) _DocumentVersion(ctx context.Context, sel ast.Select
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._DocumentVersion_approver(ctx, field, obj)
res = ec._DocumentVersion_approvers(ctx, field, obj)
if res == graphql.Null {
atomic.AddUint32(&fs.Invalids, 1)
}

View File

@@ -80,9 +80,6 @@ func NewDocument(document *coredata.Document) *Document {
Organization: &Organization{
ID: document.OrganizationID,
},
Approver: &Profile{
ID: document.ApproverID,
},
DocumentType: document.DocumentType,
Classification: document.Classification,
CurrentPublishedVersion: document.CurrentPublishedVersion,

View File

@@ -76,9 +76,6 @@ func NewDocumentVersion(documentVersion *coredata.DocumentVersion) *DocumentVers
Document: &Document{
ID: documentVersion.DocumentID,
},
Approver: &Profile{
ID: documentVersion.ApproverID,
},
Version: documentVersion.VersionNumber,
Title: documentVersion.Title,
Content: documentVersion.Content,

View File

@@ -369,7 +369,7 @@ type CreateDocumentInput struct {
OrganizationID gid.GID `json:"organizationId"`
Title string `json:"title"`
Content string `json:"content"`
ApproverID gid.GID `json:"approverId"`
ApproverIds []gid.GID `json:"approverIds"`
DocumentType coredata.DocumentType `json:"documentType"`
Classification coredata.DocumentClassification `json:"classification"`
TrustCenterVisibility *coredata.TrustCenterVisibility `json:"trustCenterVisibility,omitempty"`
@@ -1129,7 +1129,7 @@ type Document struct {
Classification coredata.DocumentClassification `json:"classification"`
CurrentPublishedVersion *int `json:"currentPublishedVersion,omitempty"`
TrustCenterVisibility coredata.TrustCenterVisibility `json:"trustCenterVisibility"`
Approver *Profile `json:"approver"`
Approvers *ProfileConnection `json:"approvers"`
Organization *Organization `json:"organization"`
Versions *DocumentVersionConnection `json:"versions"`
Controls *ControlConnection `json:"controls"`
@@ -1159,7 +1159,7 @@ type DocumentVersion struct {
Changelog string `json:"changelog"`
Title string `json:"title"`
Classification coredata.DocumentClassification `json:"classification"`
Approver *Profile `json:"approver"`
Approvers *ProfileConnection `json:"approvers"`
Signatures *DocumentVersionSignatureConnection `json:"signatures"`
Signed bool `json:"signed"`
PublishedAt *time.Time `json:"publishedAt,omitempty"`
@@ -2036,7 +2036,7 @@ type UpdateDocumentInput struct {
ID gid.GID `json:"id"`
Title *string `json:"title,omitempty"`
Content *string `json:"content,omitempty"`
ApproverID *gid.GID `json:"approverId,omitempty"`
ApproverIds []gid.GID `json:"approverIds,omitempty"`
DocumentType *coredata.DocumentType `json:"documentType,omitempty"`
Classification *coredata.DocumentClassification `json:"classification,omitempty"`
TrustCenterVisibility *coredata.TrustCenterVisibility `json:"trustCenterVisibility,omitempty"`

View File

@@ -862,23 +862,39 @@ func (r *datumConnectionResolver) TotalCount(ctx context.Context, obj *types.Dat
panic(fmt.Errorf("unsupported resolver: %T", obj.Resolver))
}
// Approver is the resolver for the approver field.
func (r *documentResolver) Approver(ctx context.Context, obj *types.Document) (*types.Profile, error) {
if err := r.authorize(ctx, obj.ID, iam.ActionMembershipProfileGet); err != nil {
// Approvers is the resolver for the approvers field.
func (r *documentResolver) Approvers(ctx context.Context, obj *types.Document, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ProfileOrderBy) (*types.ProfileConnection, error) {
if err := r.authorize(ctx, obj.ID, iam.ActionMembershipProfileList); err != nil {
return nil, err
}
approver, err := r.iam.OrganizationService.GetProfile(ctx, obj.Approver.ID)
if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
return nil, gqlutils.NotFound(ctx, err)
}
// TODO no panic use gqlutils.InternalError
panic(fmt.Errorf("cannot get approver: %w", err))
if gqlutils.OnlyTotalCountSelected(ctx) {
return &types.ProfileConnection{
Resolver: r,
ParentID: obj.ID,
}, nil
}
return types.NewProfile(approver), nil
prb := r.ProboService(ctx, obj.ID.TenantID())
pageOrderBy := page.OrderBy[coredata.MembershipProfileOrderField]{
Field: coredata.MembershipProfileOrderFieldCreatedAt,
Direction: page.OrderDirectionDesc,
}
if orderBy != nil {
pageOrderBy.Field = coredata.MembershipProfileOrderField(orderBy.Field)
pageOrderBy.Direction = page.OrderDirection(orderBy.Direction)
}
c := types.NewCursor(first, after, last, before, pageOrderBy)
p, err := prb.Documents.ListApprovers(ctx, obj.ID, c)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot list document approvers", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return types.NewProfileConnection(p, r, obj.ID, nil), nil
}
// Organization is the resolver for the organization field.
@@ -1031,23 +1047,39 @@ func (r *documentVersionResolver) Document(ctx context.Context, obj *types.Docum
return types.NewDocument(document), nil
}
// Approver is the resolver for the approver field.
func (r *documentVersionResolver) Approver(ctx context.Context, obj *types.DocumentVersion) (*types.Profile, error) {
if err := r.authorize(ctx, obj.ID, iam.ActionMembershipProfileGet); err != nil {
// Approvers is the resolver for the approvers field.
func (r *documentVersionResolver) Approvers(ctx context.Context, obj *types.DocumentVersion, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ProfileOrderBy) (*types.ProfileConnection, error) {
if err := r.authorize(ctx, obj.ID, iam.ActionMembershipProfileList); err != nil {
return nil, err
}
approver, err := r.iam.OrganizationService.GetProfile(ctx, obj.Approver.ID)
if err != nil {
if errors.Is(err, coredata.ErrResourceNotFound) {
return nil, gqlutils.NotFound(ctx, err)
}
// TODO no panic use gqlutils.InternalError
panic(fmt.Errorf("cannot get approver: %w", err))
if gqlutils.OnlyTotalCountSelected(ctx) {
return &types.ProfileConnection{
Resolver: r,
ParentID: obj.ID,
}, nil
}
return types.NewProfile(approver), nil
prb := r.ProboService(ctx, obj.ID.TenantID())
pageOrderBy := page.OrderBy[coredata.MembershipProfileOrderField]{
Field: coredata.MembershipProfileOrderFieldCreatedAt,
Direction: page.OrderDirectionDesc,
}
if orderBy != nil {
pageOrderBy.Field = coredata.MembershipProfileOrderField(orderBy.Field)
pageOrderBy.Direction = page.OrderDirection(orderBy.Direction)
}
c := types.NewCursor(first, after, last, before, pageOrderBy)
p, err := prb.Documents.ListVersionApprovers(ctx, obj.ID, c)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot list document version approvers", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return types.NewProfileConnection(p, r, obj.ID, nil), nil
}
// Signatures is the resolver for the signatures field.
@@ -3528,7 +3560,7 @@ func (r *mutationResolver) CreateDocument(ctx context.Context, input types.Creat
OrganizationID: input.OrganizationID,
DocumentType: input.DocumentType,
Title: input.Title,
ApproverID: input.ApproverID,
ApproverIDs: input.ApproverIds,
Content: input.Content,
Classification: input.Classification,
TrustCenterVisibility: input.TrustCenterVisibility,
@@ -3562,7 +3594,7 @@ func (r *mutationResolver) UpdateDocument(ctx context.Context, input types.Updat
probo.UpdateDocumentRequest{
DocumentID: input.ID,
Title: input.Title,
ApproverID: input.ApproverID,
ApproverIDs: input.ApproverIds,
Classification: input.Classification,
DocumentType: input.DocumentType,
TrustCenterVisibility: input.TrustCenterVisibility,
@@ -6576,6 +6608,20 @@ func (r *profileConnectionResolver) TotalCount(ctx context.Context, obj *types.P
panic(fmt.Errorf("cannot count profiles: %w", err))
}
return count, nil
case *documentResolver:
prb := r.ProboService(ctx, obj.ParentID.TenantID())
count, err := prb.Documents.CountApprovers(ctx, obj.ParentID)
if err != nil {
panic(fmt.Errorf("cannot count document approvers: %w", err))
}
return count, nil
case *documentVersionResolver:
prb := r.ProboService(ctx, obj.ParentID.TenantID())
count, err := prb.Documents.CountVersionApprovers(ctx, obj.ParentID)
if err != nil {
panic(fmt.Errorf("cannot count document version approvers: %w", err))
}
return count, nil
}
panic(fmt.Errorf("not implemented: TotalCount for parent type %T", obj.Resolver))