Add vendor business and security owner
Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
2
pkg/coredata/migrations/20250412T141800Z.sql
Normal file
2
pkg/coredata/migrations/20250412T141800Z.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE vendors ADD COLUMN business_owner_id TEXT REFERENCES peoples(id) ON DELETE SET NULL;
|
||||
ALTER TABLE vendors ADD COLUMN security_owner_id TEXT REFERENCES peoples(id) ON DELETE SET NULL;
|
||||
@@ -47,6 +47,8 @@ type (
|
||||
Certifications []string `db:"certifications"`
|
||||
ServiceCriticality ServiceCriticality `db:"service_criticality"`
|
||||
RiskTier RiskTier `db:"risk_tier"`
|
||||
BusinessOwnerID *gid.GID `db:"business_owner_id"`
|
||||
SecurityOwnerID *gid.GID `db:"security_owner_id"`
|
||||
StatusPageURL *string `db:"status_page_url"`
|
||||
TermsOfServiceURL *string `db:"terms_of_service_url"`
|
||||
SecurityPageURL *string `db:"security_page_url"`
|
||||
@@ -93,6 +95,8 @@ SELECT
|
||||
certifications,
|
||||
service_criticality,
|
||||
risk_tier,
|
||||
business_owner_id,
|
||||
security_owner_id,
|
||||
status_page_url,
|
||||
terms_of_service_url,
|
||||
security_page_url,
|
||||
@@ -153,6 +157,8 @@ INSERT INTO
|
||||
service_termination_at,
|
||||
service_criticality,
|
||||
risk_tier,
|
||||
business_owner_id,
|
||||
security_owner_id,
|
||||
status_page_url,
|
||||
terms_of_service_url,
|
||||
security_page_url,
|
||||
@@ -178,6 +184,8 @@ VALUES (
|
||||
@service_termination_at,
|
||||
@service_criticality,
|
||||
@risk_tier,
|
||||
@business_owner_id,
|
||||
@security_owner_id,
|
||||
@status_page_url,
|
||||
@terms_of_service_url,
|
||||
@security_page_url,
|
||||
@@ -205,6 +213,8 @@ VALUES (
|
||||
"service_termination_at": v.ServiceTerminationAt,
|
||||
"service_criticality": v.ServiceCriticality,
|
||||
"risk_tier": v.RiskTier,
|
||||
"business_owner_id": v.BusinessOwnerID,
|
||||
"security_owner_id": v.SecurityOwnerID,
|
||||
"status_page_url": v.StatusPageURL,
|
||||
"terms_of_service_url": v.TermsOfServiceURL,
|
||||
"security_page_url": v.SecurityPageURL,
|
||||
@@ -259,6 +269,8 @@ SELECT
|
||||
service_termination_at,
|
||||
service_criticality,
|
||||
risk_tier,
|
||||
business_owner_id,
|
||||
security_owner_id,
|
||||
status_page_url,
|
||||
terms_of_service_url,
|
||||
security_page_url,
|
||||
@@ -319,6 +331,8 @@ SET
|
||||
terms_of_service_url = @terms_of_service_url,
|
||||
security_page_url = @security_page_url,
|
||||
trust_page_url = @trust_page_url,
|
||||
business_owner_id = @business_owner_id,
|
||||
security_owner_id = @security_owner_id,
|
||||
updated_at = @updated_at
|
||||
WHERE %s
|
||||
AND id = @vendor_id
|
||||
@@ -346,6 +360,8 @@ WHERE %s
|
||||
"terms_of_service_url": v.TermsOfServiceURL,
|
||||
"security_page_url": v.SecurityPageURL,
|
||||
"trust_page_url": v.TrustPageURL,
|
||||
"business_owner_id": v.BusinessOwnerID,
|
||||
"security_owner_id": v.SecurityOwnerID,
|
||||
}
|
||||
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
@@ -50,6 +50,8 @@ type (
|
||||
ServiceTerminationAt *time.Time
|
||||
ServiceCriticality coredata.ServiceCriticality
|
||||
RiskTier coredata.RiskTier
|
||||
BusinessOwnerID *gid.GID
|
||||
SecurityOwnerID *gid.GID
|
||||
}
|
||||
|
||||
UpdateVendorRequest struct {
|
||||
@@ -72,6 +74,8 @@ type (
|
||||
ServiceTerminationAt *time.Time
|
||||
ServiceCriticality *coredata.ServiceCriticality
|
||||
RiskTier *coredata.RiskTier
|
||||
BusinessOwnerID *gid.GID
|
||||
SecurityOwnerID *gid.GID
|
||||
}
|
||||
)
|
||||
|
||||
@@ -203,6 +207,14 @@ func (s VendorService) Update(
|
||||
vendor.TrustPageURL = req.TrustPageURL
|
||||
}
|
||||
|
||||
if req.BusinessOwnerID != nil {
|
||||
vendor.BusinessOwnerID = req.BusinessOwnerID
|
||||
}
|
||||
|
||||
if req.SecurityOwnerID != nil {
|
||||
vendor.SecurityOwnerID = req.SecurityOwnerID
|
||||
}
|
||||
|
||||
vendor.UpdatedAt = time.Now()
|
||||
|
||||
if err := vendor.Update(ctx, conn, s.svc.scope); err != nil {
|
||||
|
||||
@@ -457,6 +457,9 @@ type Vendor implements Node {
|
||||
orderBy: VendorComplianceReportOrder
|
||||
): VendorComplianceReportConnection! @goField(forceResolver: true)
|
||||
|
||||
businessOwner: People @goField(forceResolver: true)
|
||||
securityOwner: People @goField(forceResolver: true)
|
||||
|
||||
serviceStartAt: Datetime!
|
||||
serviceTerminationAt: Datetime
|
||||
serviceCriticality: ServiceCriticality!
|
||||
@@ -943,6 +946,8 @@ input CreateVendorInput {
|
||||
serviceTerminationAt: Datetime
|
||||
serviceCriticality: ServiceCriticality!
|
||||
riskTier: RiskTier!
|
||||
businessOwnerId: ID
|
||||
securityOwnerId: ID
|
||||
}
|
||||
|
||||
input UpdateVendorInput {
|
||||
@@ -965,6 +970,8 @@ input UpdateVendorInput {
|
||||
certifications: [String!]
|
||||
securityPageUrl: String
|
||||
trustPageUrl: String
|
||||
businessOwnerId: ID
|
||||
securityOwnerId: ID
|
||||
}
|
||||
|
||||
input DeleteVendorInput {
|
||||
|
||||
@@ -526,6 +526,7 @@ type ComplexityRoot struct {
|
||||
}
|
||||
|
||||
Vendor struct {
|
||||
BusinessOwner func(childComplexity int) int
|
||||
Certifications func(childComplexity int) int
|
||||
ComplianceReports func(childComplexity int, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.VendorComplianceReportOrderBy) int
|
||||
CreatedAt func(childComplexity int) int
|
||||
@@ -537,6 +538,7 @@ type ComplexityRoot struct {
|
||||
Name func(childComplexity int) int
|
||||
PrivacyPolicyURL func(childComplexity int) int
|
||||
RiskTier func(childComplexity int) int
|
||||
SecurityOwner func(childComplexity int) int
|
||||
SecurityPageURL func(childComplexity int) int
|
||||
ServiceCriticality func(childComplexity int) int
|
||||
ServiceLevelAgreementURL func(childComplexity int) int
|
||||
@@ -679,6 +681,8 @@ type TaskResolver interface {
|
||||
}
|
||||
type VendorResolver interface {
|
||||
ComplianceReports(ctx context.Context, obj *types.Vendor, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.VendorComplianceReportOrderBy) (*types.VendorComplianceReportConnection, error)
|
||||
BusinessOwner(ctx context.Context, obj *types.Vendor) (*types.People, error)
|
||||
SecurityOwner(ctx context.Context, obj *types.Vendor) (*types.People, error)
|
||||
}
|
||||
type VendorComplianceReportResolver interface {
|
||||
Vendor(ctx context.Context, obj *types.VendorComplianceReport) (*types.Vendor, error)
|
||||
@@ -2633,6 +2637,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||
|
||||
return e.complexity.UserEdge.Node(childComplexity), true
|
||||
|
||||
case "Vendor.businessOwner":
|
||||
if e.complexity.Vendor.BusinessOwner == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Vendor.BusinessOwner(childComplexity), true
|
||||
|
||||
case "Vendor.certifications":
|
||||
if e.complexity.Vendor.Certifications == nil {
|
||||
break
|
||||
@@ -2715,6 +2726,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||
|
||||
return e.complexity.Vendor.RiskTier(childComplexity), true
|
||||
|
||||
case "Vendor.securityOwner":
|
||||
if e.complexity.Vendor.SecurityOwner == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Vendor.SecurityOwner(childComplexity), true
|
||||
|
||||
case "Vendor.securityPageUrl":
|
||||
if e.complexity.Vendor.SecurityPageURL == nil {
|
||||
break
|
||||
@@ -3550,6 +3568,9 @@ type Vendor implements Node {
|
||||
orderBy: VendorComplianceReportOrder
|
||||
): VendorComplianceReportConnection! @goField(forceResolver: true)
|
||||
|
||||
businessOwner: People @goField(forceResolver: true)
|
||||
securityOwner: People @goField(forceResolver: true)
|
||||
|
||||
serviceStartAt: Datetime!
|
||||
serviceTerminationAt: Datetime
|
||||
serviceCriticality: ServiceCriticality!
|
||||
@@ -4036,6 +4057,8 @@ input CreateVendorInput {
|
||||
serviceTerminationAt: Datetime
|
||||
serviceCriticality: ServiceCriticality!
|
||||
riskTier: RiskTier!
|
||||
businessOwnerId: ID
|
||||
securityOwnerId: ID
|
||||
}
|
||||
|
||||
input UpdateVendorInput {
|
||||
@@ -4058,6 +4081,8 @@ input UpdateVendorInput {
|
||||
certifications: [String!]
|
||||
securityPageUrl: String
|
||||
trustPageUrl: String
|
||||
businessOwnerId: ID
|
||||
securityOwnerId: ID
|
||||
}
|
||||
|
||||
input DeleteVendorInput {
|
||||
@@ -18974,6 +18999,10 @@ func (ec *executionContext) fieldContext_UpdateVendorPayload_vendor(_ context.Co
|
||||
return ec.fieldContext_Vendor_description(ctx, field)
|
||||
case "complianceReports":
|
||||
return ec.fieldContext_Vendor_complianceReports(ctx, field)
|
||||
case "businessOwner":
|
||||
return ec.fieldContext_Vendor_businessOwner(ctx, field)
|
||||
case "securityOwner":
|
||||
return ec.fieldContext_Vendor_securityOwner(ctx, field)
|
||||
case "serviceStartAt":
|
||||
return ec.fieldContext_Vendor_serviceStartAt(ctx, field)
|
||||
case "serviceTerminationAt":
|
||||
@@ -19679,6 +19708,120 @@ func (ec *executionContext) fieldContext_Vendor_complianceReports(ctx context.Co
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Vendor_businessOwner(ctx context.Context, field graphql.CollectedField, obj *types.Vendor) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Vendor_businessOwner(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.Vendor().BusinessOwner(rctx, obj)
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(*types.People)
|
||||
fc.Result = res
|
||||
return ec.marshalOPeople2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐPeople(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Vendor_businessOwner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "Vendor",
|
||||
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_People_id(ctx, field)
|
||||
case "fullName":
|
||||
return ec.fieldContext_People_fullName(ctx, field)
|
||||
case "primaryEmailAddress":
|
||||
return ec.fieldContext_People_primaryEmailAddress(ctx, field)
|
||||
case "additionalEmailAddresses":
|
||||
return ec.fieldContext_People_additionalEmailAddresses(ctx, field)
|
||||
case "kind":
|
||||
return ec.fieldContext_People_kind(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_People_createdAt(ctx, field)
|
||||
case "updatedAt":
|
||||
return ec.fieldContext_People_updatedAt(ctx, field)
|
||||
}
|
||||
return nil, fmt.Errorf("no field named %q was found under type People", field.Name)
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Vendor_securityOwner(ctx context.Context, field graphql.CollectedField, obj *types.Vendor) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Vendor_securityOwner(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.Vendor().SecurityOwner(rctx, obj)
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(*types.People)
|
||||
fc.Result = res
|
||||
return ec.marshalOPeople2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋserverᚋapiᚋconsoleᚋv1ᚋtypesᚐPeople(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Vendor_securityOwner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "Vendor",
|
||||
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_People_id(ctx, field)
|
||||
case "fullName":
|
||||
return ec.fieldContext_People_fullName(ctx, field)
|
||||
case "primaryEmailAddress":
|
||||
return ec.fieldContext_People_primaryEmailAddress(ctx, field)
|
||||
case "additionalEmailAddresses":
|
||||
return ec.fieldContext_People_additionalEmailAddresses(ctx, field)
|
||||
case "kind":
|
||||
return ec.fieldContext_People_kind(ctx, field)
|
||||
case "createdAt":
|
||||
return ec.fieldContext_People_createdAt(ctx, field)
|
||||
case "updatedAt":
|
||||
return ec.fieldContext_People_updatedAt(ctx, field)
|
||||
}
|
||||
return nil, fmt.Errorf("no field named %q was found under type People", field.Name)
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Vendor_serviceStartAt(ctx context.Context, field graphql.CollectedField, obj *types.Vendor) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Vendor_serviceStartAt(ctx, field)
|
||||
if err != nil {
|
||||
@@ -20485,6 +20628,10 @@ func (ec *executionContext) fieldContext_VendorComplianceReport_vendor(_ context
|
||||
return ec.fieldContext_Vendor_description(ctx, field)
|
||||
case "complianceReports":
|
||||
return ec.fieldContext_Vendor_complianceReports(ctx, field)
|
||||
case "businessOwner":
|
||||
return ec.fieldContext_Vendor_businessOwner(ctx, field)
|
||||
case "securityOwner":
|
||||
return ec.fieldContext_Vendor_securityOwner(ctx, field)
|
||||
case "serviceStartAt":
|
||||
return ec.fieldContext_Vendor_serviceStartAt(ctx, field)
|
||||
case "serviceTerminationAt":
|
||||
@@ -21238,6 +21385,10 @@ func (ec *executionContext) fieldContext_VendorEdge_node(_ context.Context, fiel
|
||||
return ec.fieldContext_Vendor_description(ctx, field)
|
||||
case "complianceReports":
|
||||
return ec.fieldContext_Vendor_complianceReports(ctx, field)
|
||||
case "businessOwner":
|
||||
return ec.fieldContext_Vendor_businessOwner(ctx, field)
|
||||
case "securityOwner":
|
||||
return ec.fieldContext_Vendor_securityOwner(ctx, field)
|
||||
case "serviceStartAt":
|
||||
return ec.fieldContext_Vendor_serviceStartAt(ctx, field)
|
||||
case "serviceTerminationAt":
|
||||
@@ -24069,7 +24220,7 @@ func (ec *executionContext) unmarshalInputCreateVendorInput(ctx context.Context,
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"organizationId", "name", "description", "headquarterAddress", "legalName", "websiteUrl", "privacyPolicyUrl", "category", "serviceLevelAgreementUrl", "dataProcessingAgreementUrl", "certifications", "securityPageUrl", "trustPageUrl", "statusPageUrl", "termsOfServiceUrl", "serviceStartAt", "serviceTerminationAt", "serviceCriticality", "riskTier"}
|
||||
fieldsInOrder := [...]string{"organizationId", "name", "description", "headquarterAddress", "legalName", "websiteUrl", "privacyPolicyUrl", "category", "serviceLevelAgreementUrl", "dataProcessingAgreementUrl", "certifications", "securityPageUrl", "trustPageUrl", "statusPageUrl", "termsOfServiceUrl", "serviceStartAt", "serviceTerminationAt", "serviceCriticality", "riskTier", "businessOwnerId", "securityOwnerId"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
@@ -24209,6 +24360,20 @@ func (ec *executionContext) unmarshalInputCreateVendorInput(ctx context.Context,
|
||||
return it, err
|
||||
}
|
||||
it.RiskTier = data
|
||||
case "businessOwnerId":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("businessOwnerId"))
|
||||
data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.BusinessOwnerID = data
|
||||
case "securityOwnerId":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("securityOwnerId"))
|
||||
data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.SecurityOwnerID = data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25538,7 +25703,7 @@ func (ec *executionContext) unmarshalInputUpdateVendorInput(ctx context.Context,
|
||||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"id", "name", "description", "serviceStartAt", "serviceTerminationAt", "serviceCriticality", "riskTier", "statusPageUrl", "termsOfServiceUrl", "privacyPolicyUrl", "serviceLevelAgreementUrl", "dataProcessingAgreementUrl", "websiteUrl", "legalName", "headquarterAddress", "category", "certifications", "securityPageUrl", "trustPageUrl"}
|
||||
fieldsInOrder := [...]string{"id", "name", "description", "serviceStartAt", "serviceTerminationAt", "serviceCriticality", "riskTier", "statusPageUrl", "termsOfServiceUrl", "privacyPolicyUrl", "serviceLevelAgreementUrl", "dataProcessingAgreementUrl", "websiteUrl", "legalName", "headquarterAddress", "category", "certifications", "securityPageUrl", "trustPageUrl", "businessOwnerId", "securityOwnerId"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
@@ -25678,6 +25843,20 @@ func (ec *executionContext) unmarshalInputUpdateVendorInput(ctx context.Context,
|
||||
return it, err
|
||||
}
|
||||
it.TrustPageURL = data
|
||||
case "businessOwnerId":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("businessOwnerId"))
|
||||
data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.BusinessOwnerID = data
|
||||
case "securityOwnerId":
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("securityOwnerId"))
|
||||
data, err := ec.unmarshalOID2ᚖgithubᚗcomᚋgetproboᚋproboᚋpkgᚋgidᚐGID(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
it.SecurityOwnerID = data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30634,6 +30813,72 @@ func (ec *executionContext) _Vendor(ctx context.Context, sel ast.SelectionSet, o
|
||||
continue
|
||||
}
|
||||
|
||||
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
|
||||
case "businessOwner":
|
||||
field := field
|
||||
|
||||
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
}
|
||||
}()
|
||||
res = ec._Vendor_businessOwner(ctx, field, obj)
|
||||
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) })
|
||||
case "securityOwner":
|
||||
field := field
|
||||
|
||||
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
}
|
||||
}()
|
||||
res = ec._Vendor_securityOwner(ctx, field, obj)
|
||||
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) })
|
||||
case "serviceStartAt":
|
||||
out.Values[i] = ec._Vendor_serviceStartAt(ctx, field, obj)
|
||||
|
||||
@@ -212,6 +212,8 @@ type CreateVendorInput struct {
|
||||
ServiceTerminationAt *time.Time `json:"serviceTerminationAt,omitempty"`
|
||||
ServiceCriticality coredata.ServiceCriticality `json:"serviceCriticality"`
|
||||
RiskTier coredata.RiskTier `json:"riskTier"`
|
||||
BusinessOwnerID *gid.GID `json:"businessOwnerId,omitempty"`
|
||||
SecurityOwnerID *gid.GID `json:"securityOwnerId,omitempty"`
|
||||
}
|
||||
|
||||
type CreateVendorPayload struct {
|
||||
@@ -731,6 +733,8 @@ type UpdateVendorInput struct {
|
||||
Certifications []string `json:"certifications,omitempty"`
|
||||
SecurityPageURL *string `json:"securityPageUrl,omitempty"`
|
||||
TrustPageURL *string `json:"trustPageUrl,omitempty"`
|
||||
BusinessOwnerID *gid.GID `json:"businessOwnerId,omitempty"`
|
||||
SecurityOwnerID *gid.GID `json:"securityOwnerId,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateVendorPayload struct {
|
||||
@@ -775,6 +779,8 @@ type Vendor struct {
|
||||
Name string `json:"name"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
ComplianceReports *VendorComplianceReportConnection `json:"complianceReports"`
|
||||
BusinessOwner *People `json:"businessOwner,omitempty"`
|
||||
SecurityOwner *People `json:"securityOwner,omitempty"`
|
||||
ServiceStartAt time.Time `json:"serviceStartAt"`
|
||||
ServiceTerminationAt *time.Time `json:"serviceTerminationAt,omitempty"`
|
||||
ServiceCriticality coredata.ServiceCriticality `json:"serviceCriticality"`
|
||||
|
||||
@@ -377,6 +377,8 @@ func (r *mutationResolver) CreateVendor(ctx context.Context, input types.CreateV
|
||||
Certifications: input.Certifications,
|
||||
SecurityPageURL: input.SecurityPageURL,
|
||||
TrustPageURL: input.TrustPageURL,
|
||||
BusinessOwnerID: input.BusinessOwnerID,
|
||||
SecurityOwnerID: input.SecurityOwnerID,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -411,6 +413,8 @@ func (r *mutationResolver) UpdateVendor(ctx context.Context, input types.UpdateV
|
||||
WebsiteURL: input.WebsiteURL,
|
||||
Category: input.Category,
|
||||
Certifications: input.Certifications,
|
||||
BusinessOwnerID: input.BusinessOwnerID,
|
||||
SecurityOwnerID: input.SecurityOwnerID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot update vendor: %w", err)
|
||||
@@ -1513,6 +1517,48 @@ func (r *vendorResolver) ComplianceReports(ctx context.Context, obj *types.Vendo
|
||||
return types.NewVendorComplianceReportConnection(page), nil
|
||||
}
|
||||
|
||||
// BusinessOwner is the resolver for the businessOwner field.
|
||||
func (r *vendorResolver) BusinessOwner(ctx context.Context, obj *types.Vendor) (*types.People, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
|
||||
vendor, err := svc.Vendors.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to get vendor: %w", err))
|
||||
}
|
||||
|
||||
if vendor.BusinessOwnerID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
people, err := svc.Peoples.Get(ctx, *vendor.BusinessOwnerID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to get business owner: %w", err))
|
||||
}
|
||||
|
||||
return types.NewPeople(people), nil
|
||||
}
|
||||
|
||||
// SecurityOwner is the resolver for the securityOwner field.
|
||||
func (r *vendorResolver) SecurityOwner(ctx context.Context, obj *types.Vendor) (*types.People, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
|
||||
vendor, err := svc.Vendors.Get(ctx, obj.ID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to get vendor: %w", err))
|
||||
}
|
||||
|
||||
if vendor.SecurityOwnerID == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
people, err := svc.Peoples.Get(ctx, *vendor.SecurityOwnerID)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to get security owner: %w", err))
|
||||
}
|
||||
|
||||
return types.NewPeople(people), nil
|
||||
}
|
||||
|
||||
// Vendor is the resolver for the vendor field.
|
||||
func (r *vendorComplianceReportResolver) Vendor(ctx context.Context, obj *types.VendorComplianceReport) (*types.Vendor, error) {
|
||||
svc := r.GetTenantServiceIfAuthorized(ctx, obj.ID.TenantID())
|
||||
|
||||
Reference in New Issue
Block a user