Add graphql resolver

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2025-07-03 11:58:29 +02:00
parent 68b422e06b
commit 8189fa2a14
4 changed files with 289 additions and 0 deletions

View File

@@ -1397,6 +1397,9 @@ type Mutation {
sendSigningNotifications( sendSigningNotifications(
input: SendSigningNotificationsInput! input: SendSigningNotificationsInput!
): SendSigningNotificationsPayload! ): SendSigningNotificationsPayload!
exportDocumentVersionPDF(
input: ExportDocumentVersionPDFInput!
): ExportDocumentVersionPDFPayload!
createVendorRiskAssessment( createVendorRiskAssessment(
input: CreateVendorRiskAssessmentInput! input: CreateVendorRiskAssessmentInput!
@@ -1709,6 +1712,10 @@ input UpdateDocumentInput {
documentType: DocumentType documentType: DocumentType
} }
input ExportDocumentVersionPDFInput {
documentVersionId: ID!
}
input DeleteDocumentInput { input DeleteDocumentInput {
documentId: ID! documentId: ID!
} }
@@ -1920,6 +1927,10 @@ type CreateDocumentPayload {
documentVersionEdge: DocumentVersionEdge! documentVersionEdge: DocumentVersionEdge!
} }
type ExportDocumentVersionPDFPayload {
data: String!
}
type UpdateDocumentPayload { type UpdateDocumentPayload {
document: Document! document: Document!
} }

View File

@@ -427,6 +427,10 @@ type ComplexityRoot struct {
URL func(childComplexity int) int URL func(childComplexity int) int
} }
ExportDocumentVersionPDFPayload struct {
Data func(childComplexity int) int
}
Framework struct { Framework struct {
Controls func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ControlOrderBy, filter *types.ControlFilter) 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 CreatedAt func(childComplexity int) int
@@ -535,6 +539,7 @@ type ComplexityRoot struct {
DeleteVendor func(childComplexity int, input types.DeleteVendorInput) int DeleteVendor func(childComplexity int, input types.DeleteVendorInput) int
DeleteVendorComplianceReport func(childComplexity int, input types.DeleteVendorComplianceReportInput) int DeleteVendorComplianceReport func(childComplexity int, input types.DeleteVendorComplianceReportInput) int
ExportAudit func(childComplexity int, input types.ExportAuditInput) int ExportAudit func(childComplexity int, input types.ExportAuditInput) int
ExportDocumentVersionPDF func(childComplexity int, input types.ExportDocumentVersionPDFInput) int
FulfillEvidence func(childComplexity int, input types.FulfillEvidenceInput) int FulfillEvidence func(childComplexity int, input types.FulfillEvidenceInput) int
GenerateDocumentChangelog func(childComplexity int, input types.GenerateDocumentChangelogInput) int GenerateDocumentChangelog func(childComplexity int, input types.GenerateDocumentChangelogInput) int
GenerateFrameworkStateOfApplicability func(childComplexity int, input types.GenerateFrameworkStateOfApplicabilityInput) int GenerateFrameworkStateOfApplicability func(childComplexity int, input types.GenerateFrameworkStateOfApplicabilityInput) int
@@ -1019,6 +1024,7 @@ type MutationResolver interface {
UpdateDocumentVersion(ctx context.Context, input types.UpdateDocumentVersionInput) (*types.UpdateDocumentVersionPayload, error) UpdateDocumentVersion(ctx context.Context, input types.UpdateDocumentVersionInput) (*types.UpdateDocumentVersionPayload, error)
RequestSignature(ctx context.Context, input types.RequestSignatureInput) (*types.RequestSignaturePayload, error) RequestSignature(ctx context.Context, input types.RequestSignatureInput) (*types.RequestSignaturePayload, error)
SendSigningNotifications(ctx context.Context, input types.SendSigningNotificationsInput) (*types.SendSigningNotificationsPayload, error) SendSigningNotifications(ctx context.Context, input types.SendSigningNotificationsInput) (*types.SendSigningNotificationsPayload, error)
ExportDocumentVersionPDF(ctx context.Context, input types.ExportDocumentVersionPDFInput) (*types.ExportDocumentVersionPDFPayload, error)
CreateVendorRiskAssessment(ctx context.Context, input types.CreateVendorRiskAssessmentInput) (*types.CreateVendorRiskAssessmentPayload, error) CreateVendorRiskAssessment(ctx context.Context, input types.CreateVendorRiskAssessmentInput) (*types.CreateVendorRiskAssessmentPayload, error)
ExportAudit(ctx context.Context, input types.ExportAuditInput) (*types.ExportAuditPayload, error) ExportAudit(ctx context.Context, input types.ExportAuditInput) (*types.ExportAuditPayload, error)
AssessVendor(ctx context.Context, input types.AssessVendorInput) (*types.AssessVendorPayload, error) AssessVendor(ctx context.Context, input types.AssessVendorInput) (*types.AssessVendorPayload, error)
@@ -2292,6 +2298,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
return e.complexity.ExportAuditPayload.URL(childComplexity), true return e.complexity.ExportAuditPayload.URL(childComplexity), true
case "ExportDocumentVersionPDFPayload.data":
if e.complexity.ExportDocumentVersionPDFPayload.Data == nil {
break
}
return e.complexity.ExportDocumentVersionPDFPayload.Data(childComplexity), true
case "Framework.controls": case "Framework.controls":
if e.complexity.Framework.Controls == nil { if e.complexity.Framework.Controls == nil {
break break
@@ -2999,6 +3012,18 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
return e.complexity.Mutation.ExportAudit(childComplexity, args["input"].(types.ExportAuditInput)), true return e.complexity.Mutation.ExportAudit(childComplexity, args["input"].(types.ExportAuditInput)), true
case "Mutation.exportDocumentVersionPDF":
if e.complexity.Mutation.ExportDocumentVersionPDF == nil {
break
}
args, err := ec.field_Mutation_exportDocumentVersionPDF_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.complexity.Mutation.ExportDocumentVersionPDF(childComplexity, args["input"].(types.ExportDocumentVersionPDFInput)), true
case "Mutation.fulfillEvidence": case "Mutation.fulfillEvidence":
if e.complexity.Mutation.FulfillEvidence == nil { if e.complexity.Mutation.FulfillEvidence == nil {
break break
@@ -4717,6 +4742,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
ec.unmarshalInputDocumentVersionSignatureOrder, ec.unmarshalInputDocumentVersionSignatureOrder,
ec.unmarshalInputEvidenceOrder, ec.unmarshalInputEvidenceOrder,
ec.unmarshalInputExportAuditInput, ec.unmarshalInputExportAuditInput,
ec.unmarshalInputExportDocumentVersionPDFInput,
ec.unmarshalInputFrameworkOrder, ec.unmarshalInputFrameworkOrder,
ec.unmarshalInputFulfillEvidenceInput, ec.unmarshalInputFulfillEvidenceInput,
ec.unmarshalInputGenerateDocumentChangelogInput, ec.unmarshalInputGenerateDocumentChangelogInput,
@@ -6252,6 +6278,9 @@ type Mutation {
sendSigningNotifications( sendSigningNotifications(
input: SendSigningNotificationsInput! input: SendSigningNotificationsInput!
): SendSigningNotificationsPayload! ): SendSigningNotificationsPayload!
exportDocumentVersionPDF(
input: ExportDocumentVersionPDFInput!
): ExportDocumentVersionPDFPayload!
createVendorRiskAssessment( createVendorRiskAssessment(
input: CreateVendorRiskAssessmentInput! input: CreateVendorRiskAssessmentInput!
@@ -6564,6 +6593,10 @@ input UpdateDocumentInput {
documentType: DocumentType documentType: DocumentType
} }
input ExportDocumentVersionPDFInput {
documentVersionId: ID!
}
input DeleteDocumentInput { input DeleteDocumentInput {
documentId: ID! documentId: ID!
} }
@@ -6775,6 +6808,10 @@ type CreateDocumentPayload {
documentVersionEdge: DocumentVersionEdge! documentVersionEdge: DocumentVersionEdge!
} }
type ExportDocumentVersionPDFPayload {
data: String!
}
type UpdateDocumentPayload { type UpdateDocumentPayload {
document: Document! document: Document!
} }
@@ -9279,6 +9316,29 @@ func (ec *executionContext) field_Mutation_exportAudit_argsInput(
return zeroVal, nil return zeroVal, nil
} }
func (ec *executionContext) field_Mutation_exportDocumentVersionPDF_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := ec.field_Mutation_exportDocumentVersionPDF_argsInput(ctx, rawArgs)
if err != nil {
return nil, err
}
args["input"] = arg0
return args, nil
}
func (ec *executionContext) field_Mutation_exportDocumentVersionPDF_argsInput(
ctx context.Context,
rawArgs map[string]any,
) (types.ExportDocumentVersionPDFInput, error) {
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("input"))
if tmp, ok := rawArgs["input"]; ok {
return ec.unmarshalNExportDocumentVersionPDFInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐExportDocumentVersionPDFInput(ctx, tmp)
}
var zeroVal types.ExportDocumentVersionPDFInput
return zeroVal, nil
}
func (ec *executionContext) field_Mutation_fulfillEvidence_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { func (ec *executionContext) field_Mutation_fulfillEvidence_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error var err error
args := map[string]any{} args := map[string]any{}
@@ -20176,6 +20236,50 @@ func (ec *executionContext) fieldContext_ExportAuditPayload_url(_ context.Contex
return fc, nil return fc, nil
} }
func (ec *executionContext) _ExportDocumentVersionPDFPayload_data(ctx context.Context, field graphql.CollectedField, obj *types.ExportDocumentVersionPDFPayload) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_ExportDocumentVersionPDFPayload_data(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.Data, 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_ExportDocumentVersionPDFPayload_data(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "ExportDocumentVersionPDFPayload",
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) _Framework_id(ctx context.Context, field graphql.CollectedField, obj *types.Framework) (ret graphql.Marshaler) { func (ec *executionContext) _Framework_id(ctx context.Context, field graphql.CollectedField, obj *types.Framework) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Framework_id(ctx, field) fc, err := ec.fieldContext_Framework_id(ctx, field)
if err != nil { if err != nil {
@@ -25158,6 +25262,65 @@ func (ec *executionContext) fieldContext_Mutation_sendSigningNotifications(ctx c
return fc, nil return fc, nil
} }
func (ec *executionContext) _Mutation_exportDocumentVersionPDF(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Mutation_exportDocumentVersionPDF(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 ec.resolvers.Mutation().ExportDocumentVersionPDF(rctx, fc.Args["input"].(types.ExportDocumentVersionPDFInput))
})
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.(*types.ExportDocumentVersionPDFPayload)
fc.Result = res
return ec.marshalNExportDocumentVersionPDFPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐExportDocumentVersionPDFPayload(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Mutation_exportDocumentVersionPDF(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Mutation",
Field: field,
IsMethod: true,
IsResolver: true,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "data":
return ec.fieldContext_ExportDocumentVersionPDFPayload_data(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type ExportDocumentVersionPDFPayload", 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_Mutation_exportDocumentVersionPDF_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _Mutation_createVendorRiskAssessment(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { func (ec *executionContext) _Mutation_createVendorRiskAssessment(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Mutation_createVendorRiskAssessment(ctx, field) fc, err := ec.fieldContext_Mutation_createVendorRiskAssessment(ctx, field)
if err != nil { if err != nil {
@@ -38952,6 +39115,33 @@ func (ec *executionContext) unmarshalInputExportAuditInput(ctx context.Context,
return it, nil return it, nil
} }
func (ec *executionContext) unmarshalInputExportDocumentVersionPDFInput(ctx context.Context, obj any) (types.ExportDocumentVersionPDFInput, error) {
var it types.ExportDocumentVersionPDFInput
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
asMap[k] = v
}
fieldsInOrder := [...]string{"documentVersionId"}
for _, k := range fieldsInOrder {
v, ok := asMap[k]
if !ok {
continue
}
switch k {
case "documentVersionId":
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("documentVersionId"))
data, err := ec.unmarshalNID2githubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, v)
if err != nil {
return it, err
}
it.DocumentVersionID = data
}
}
return it, nil
}
func (ec *executionContext) unmarshalInputFrameworkOrder(ctx context.Context, obj any) (types.FrameworkOrderBy, error) { func (ec *executionContext) unmarshalInputFrameworkOrder(ctx context.Context, obj any) (types.FrameworkOrderBy, error) {
var it types.FrameworkOrderBy var it types.FrameworkOrderBy
asMap := map[string]any{} asMap := map[string]any{}
@@ -44628,6 +44818,45 @@ func (ec *executionContext) _ExportAuditPayload(ctx context.Context, sel ast.Sel
return out return out
} }
var exportDocumentVersionPDFPayloadImplementors = []string{"ExportDocumentVersionPDFPayload"}
func (ec *executionContext) _ExportDocumentVersionPDFPayload(ctx context.Context, sel ast.SelectionSet, obj *types.ExportDocumentVersionPDFPayload) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, exportDocumentVersionPDFPayloadImplementors)
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("ExportDocumentVersionPDFPayload")
case "data":
out.Values[i] = ec._ExportDocumentVersionPDFPayload_data(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 frameworkImplementors = []string{"Framework", "Node"} var frameworkImplementors = []string{"Framework", "Node"}
func (ec *executionContext) _Framework(ctx context.Context, sel ast.SelectionSet, obj *types.Framework) graphql.Marshaler { func (ec *executionContext) _Framework(ctx context.Context, sel ast.SelectionSet, obj *types.Framework) graphql.Marshaler {
@@ -45858,6 +46087,13 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet)
if out.Values[i] == graphql.Null { if out.Values[i] == graphql.Null {
out.Invalids++ out.Invalids++
} }
case "exportDocumentVersionPDF":
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
return ec._Mutation_exportDocumentVersionPDF(ctx, field)
})
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "createVendorRiskAssessment": case "createVendorRiskAssessment":
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
return ec._Mutation_createVendorRiskAssessment(ctx, field) return ec._Mutation_createVendorRiskAssessment(ctx, field)
@@ -51835,6 +52071,25 @@ func (ec *executionContext) marshalNExportAuditPayload2ᚖgithubᚗcomᚋgetprob
return ec._ExportAuditPayload(ctx, sel, v) return ec._ExportAuditPayload(ctx, sel, v)
} }
func (ec *executionContext) unmarshalNExportDocumentVersionPDFInput2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐExportDocumentVersionPDFInput(ctx context.Context, v any) (types.ExportDocumentVersionPDFInput, error) {
res, err := ec.unmarshalInputExportDocumentVersionPDFInput(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNExportDocumentVersionPDFPayload2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐExportDocumentVersionPDFPayload(ctx context.Context, sel ast.SelectionSet, v types.ExportDocumentVersionPDFPayload) graphql.Marshaler {
return ec._ExportDocumentVersionPDFPayload(ctx, sel, &v)
}
func (ec *executionContext) marshalNExportDocumentVersionPDFPayload2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐExportDocumentVersionPDFPayload(ctx context.Context, sel ast.SelectionSet, v *types.ExportDocumentVersionPDFPayload) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return ec._ExportDocumentVersionPDFPayload(ctx, sel, v)
}
func (ec *executionContext) marshalNFramework2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐFramework(ctx context.Context, sel ast.SelectionSet, v types.Framework) graphql.Marshaler { func (ec *executionContext) marshalNFramework2githubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐFramework(ctx context.Context, sel ast.SelectionSet, v types.Framework) graphql.Marshaler {
return ec._Framework(ctx, sel, &v) return ec._Framework(ctx, sel, &v)
} }

View File

@@ -617,6 +617,14 @@ type ExportAuditPayload struct {
URL string `json:"url"` URL string `json:"url"`
} }
type ExportDocumentVersionPDFInput struct {
DocumentVersionID gid.GID `json:"documentVersionId"`
}
type ExportDocumentVersionPDFPayload struct {
Data string `json:"data"`
}
type Framework struct { type Framework struct {
ID gid.GID `json:"id"` ID gid.GID `json:"id"`
Name string `json:"name"` Name string `json:"name"`

View File

@@ -6,6 +6,7 @@ package console_v1
import ( import (
"context" "context"
"encoding/base64"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
@@ -1928,6 +1929,20 @@ func (r *mutationResolver) SendSigningNotifications(ctx context.Context, input t
}, nil }, nil
} }
// ExportDocumentVersionPDF is the resolver for the exportDocumentVersionPDF field.
func (r *mutationResolver) ExportDocumentVersionPDF(ctx context.Context, input types.ExportDocumentVersionPDFInput) (*types.ExportDocumentVersionPDFPayload, error) {
prb := r.ProboService(ctx, input.DocumentVersionID.TenantID())
pdf, err := prb.Documents.ExportPDF(ctx, input.DocumentVersionID)
if err != nil {
panic(fmt.Errorf("cannot export document version PDF: %w", err))
}
return &types.ExportDocumentVersionPDFPayload{
Data: fmt.Sprintf("data:application/pdf;base64,%s", base64.StdEncoding.EncodeToString(pdf)),
}, nil
}
// CreateVendorRiskAssessment is the resolver for the createVendorRiskAssessment field. // CreateVendorRiskAssessment is the resolver for the createVendorRiskAssessment field.
func (r *mutationResolver) CreateVendorRiskAssessment(ctx context.Context, input types.CreateVendorRiskAssessmentInput) (*types.CreateVendorRiskAssessmentPayload, error) { func (r *mutationResolver) CreateVendorRiskAssessment(ctx context.Context, input types.CreateVendorRiskAssessmentInput) (*types.CreateVendorRiskAssessmentPayload, error) {
prb := r.ProboService(ctx, input.VendorID.TenantID()) prb := r.ProboService(ctx, input.VendorID.TenantID())