Use authorize-returned scope in Node resolver
The Node resolver was manually constructing a scope from the object ID, both at the top of the function and again inside several closures. Since r.authorize already returns the resolved scope, pass it into the loadNode closures and drop the duplicate construction. Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
@@ -24,15 +24,14 @@ import (
|
|||||||
// Node is the resolver for the node field.
|
// Node is the resolver for the node field.
|
||||||
func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error) {
|
func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error) {
|
||||||
var (
|
var (
|
||||||
loadNode func(ctx context.Context, id gid.GID) (types.Node, error)
|
loadNode func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error)
|
||||||
action string
|
action string
|
||||||
scope = coredata.NewScopeFromObjectID(id)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
switch id.EntityType() {
|
switch id.EntityType() {
|
||||||
case coredata.OrganizationEntityType:
|
case coredata.OrganizationEntityType:
|
||||||
action = iam.ActionOrganizationGet
|
action = iam.ActionOrganizationGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
organization, err := r.probo.Organizations.Get(ctx, scope, id)
|
organization, err := r.probo.Organizations.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -42,7 +41,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.ThirdPartyEntityType:
|
case coredata.ThirdPartyEntityType:
|
||||||
action = probo.ActionThirdPartyGet
|
action = probo.ActionThirdPartyGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
thirdParty, err := r.probo.ThirdParties.Get(ctx, scope, id)
|
thirdParty, err := r.probo.ThirdParties.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -52,7 +51,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.FrameworkEntityType:
|
case coredata.FrameworkEntityType:
|
||||||
action = probo.ActionFrameworkGet
|
action = probo.ActionFrameworkGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
framework, err := r.probo.Frameworks.Get(ctx, scope, id)
|
framework, err := r.probo.Frameworks.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -62,7 +61,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.MeasureEntityType:
|
case coredata.MeasureEntityType:
|
||||||
action = probo.ActionMeasureGet
|
action = probo.ActionMeasureGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
measure, err := r.probo.Measures.Get(ctx, scope, id)
|
measure, err := r.probo.Measures.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -72,7 +71,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.TaskEntityType:
|
case coredata.TaskEntityType:
|
||||||
action = probo.ActionTaskGet
|
action = probo.ActionTaskGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
task, err := r.probo.Tasks.Get(ctx, scope, id)
|
task, err := r.probo.Tasks.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -82,7 +81,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.EvidenceEntityType:
|
case coredata.EvidenceEntityType:
|
||||||
action = probo.ActionEvidenceList
|
action = probo.ActionEvidenceList
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
evidence, err := r.probo.Evidences.Get(ctx, scope, id)
|
evidence, err := r.probo.Evidences.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -92,7 +91,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.DocumentEntityType:
|
case coredata.DocumentEntityType:
|
||||||
action = probo.ActionDocumentGet
|
action = probo.ActionDocumentGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
document, err := r.probo.Documents.Get(ctx, scope, id)
|
document, err := r.probo.Documents.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -102,7 +101,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.ControlEntityType:
|
case coredata.ControlEntityType:
|
||||||
action = probo.ActionControlList
|
action = probo.ActionControlList
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
control, err := r.probo.Controls.Get(ctx, scope, id)
|
control, err := r.probo.Controls.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -112,7 +111,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.RiskEntityType:
|
case coredata.RiskEntityType:
|
||||||
action = probo.ActionRiskGet
|
action = probo.ActionRiskGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
risk, err := r.probo.Risks.Get(ctx, scope, id)
|
risk, err := r.probo.Risks.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -122,9 +121,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.RiskAssessmentEntityType:
|
case coredata.RiskAssessmentEntityType:
|
||||||
action = probo.ActionRiskAssessmentGet
|
action = probo.ActionRiskAssessmentGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
scope := coredata.NewScopeFromObjectID(id)
|
|
||||||
|
|
||||||
ra, err := r.riskManagement.Get(ctx, scope, id)
|
ra, err := r.riskManagement.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -134,9 +131,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.RiskAssessmentNodeEntityType:
|
case coredata.RiskAssessmentNodeEntityType:
|
||||||
action = probo.ActionRiskAssessmentNodeGet
|
action = probo.ActionRiskAssessmentNodeGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
scope := coredata.NewScopeFromObjectID(id)
|
|
||||||
|
|
||||||
n, err := r.riskManagement.GetNode(ctx, scope, id)
|
n, err := r.riskManagement.GetNode(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -146,9 +141,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.RiskAssessmentProcessEntityType:
|
case coredata.RiskAssessmentProcessEntityType:
|
||||||
action = probo.ActionRiskAssessmentProcessGet
|
action = probo.ActionRiskAssessmentProcessGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
scope := coredata.NewScopeFromObjectID(id)
|
|
||||||
|
|
||||||
p, err := r.riskManagement.GetProcess(ctx, scope, id)
|
p, err := r.riskManagement.GetProcess(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -158,9 +151,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.RiskAssessmentThreatEntityType:
|
case coredata.RiskAssessmentThreatEntityType:
|
||||||
action = probo.ActionRiskAssessmentThreatGet
|
action = probo.ActionRiskAssessmentThreatGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
scope := coredata.NewScopeFromObjectID(id)
|
|
||||||
|
|
||||||
t, err := r.riskManagement.GetThreat(ctx, scope, id)
|
t, err := r.riskManagement.GetThreat(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -170,9 +161,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.RiskAssessmentScopeEntityType:
|
case coredata.RiskAssessmentScopeEntityType:
|
||||||
action = probo.ActionRiskAssessmentScopeGet
|
action = probo.ActionRiskAssessmentScopeGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
scope := coredata.NewScopeFromObjectID(id)
|
|
||||||
|
|
||||||
s, err := r.riskManagement.GetScope(ctx, scope, id)
|
s, err := r.riskManagement.GetScope(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -182,9 +171,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.RiskAssessmentScenarioEntityType:
|
case coredata.RiskAssessmentScenarioEntityType:
|
||||||
action = probo.ActionRiskAssessmentScenarioGet
|
action = probo.ActionRiskAssessmentScenarioGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
scope := coredata.NewScopeFromObjectID(id)
|
|
||||||
|
|
||||||
s, err := r.riskManagement.GetScenario(ctx, scope, id)
|
s, err := r.riskManagement.GetScenario(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -194,7 +181,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.ThirdPartyComplianceReportEntityType:
|
case coredata.ThirdPartyComplianceReportEntityType:
|
||||||
action = probo.ActionThirdPartyComplianceReportGet
|
action = probo.ActionThirdPartyComplianceReportGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
thirdPartyComplianceReport, err := r.probo.ThirdPartyComplianceReports.Get(ctx, scope, id)
|
thirdPartyComplianceReport, err := r.probo.ThirdPartyComplianceReports.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -204,7 +191,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.ThirdPartyContactEntityType:
|
case coredata.ThirdPartyContactEntityType:
|
||||||
action = probo.ActionThirdPartyContactGet
|
action = probo.ActionThirdPartyContactGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
thirdPartyContact, err := r.probo.ThirdPartyContacts.Get(ctx, scope, id)
|
thirdPartyContact, err := r.probo.ThirdPartyContacts.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -214,7 +201,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.ThirdPartyServiceEntityType:
|
case coredata.ThirdPartyServiceEntityType:
|
||||||
action = probo.ActionThirdPartyServiceGet
|
action = probo.ActionThirdPartyServiceGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
thirdPartyService, err := r.probo.ThirdPartyServices.Get(ctx, scope, id)
|
thirdPartyService, err := r.probo.ThirdPartyServices.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -224,7 +211,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.DocumentVersionEntityType:
|
case coredata.DocumentVersionEntityType:
|
||||||
action = probo.ActionDocumentVersionList
|
action = probo.ActionDocumentVersionList
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
documentVersion, err := r.probo.Documents.GetVersion(ctx, scope, id)
|
documentVersion, err := r.probo.Documents.GetVersion(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -234,7 +221,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.DocumentVersionSignatureEntityType:
|
case coredata.DocumentVersionSignatureEntityType:
|
||||||
action = probo.ActionDocumentVersionSignatureList
|
action = probo.ActionDocumentVersionSignatureList
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
documentVersionSignature, err := r.probo.Documents.GetVersionSignature(ctx, scope, id)
|
documentVersionSignature, err := r.probo.Documents.GetVersionSignature(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -244,7 +231,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.AssetEntityType:
|
case coredata.AssetEntityType:
|
||||||
action = probo.ActionAssetList
|
action = probo.ActionAssetList
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
asset, err := r.probo.Assets.Get(ctx, scope, id)
|
asset, err := r.probo.Assets.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -254,7 +241,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.DatumEntityType:
|
case coredata.DatumEntityType:
|
||||||
action = probo.ActionDatumList
|
action = probo.ActionDatumList
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
datum, err := r.probo.Data.Get(ctx, scope, id)
|
datum, err := r.probo.Data.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -264,7 +251,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.AuditEntityType:
|
case coredata.AuditEntityType:
|
||||||
action = probo.ActionAuditList
|
action = probo.ActionAuditList
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
audit, err := r.probo.Audits.Get(ctx, scope, id)
|
audit, err := r.probo.Audits.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -274,7 +261,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.FindingEntityType:
|
case coredata.FindingEntityType:
|
||||||
action = probo.ActionFindingList
|
action = probo.ActionFindingList
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
finding, err := r.probo.Findings.Get(ctx, scope, id)
|
finding, err := r.probo.Findings.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -284,7 +271,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.ObligationEntityType:
|
case coredata.ObligationEntityType:
|
||||||
action = probo.ActionObligationList
|
action = probo.ActionObligationList
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
obligation, err := r.probo.Obligations.Get(ctx, scope, id)
|
obligation, err := r.probo.Obligations.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -294,7 +281,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.ReportEntityType:
|
case coredata.ReportEntityType:
|
||||||
action = probo.ActionReportGet
|
action = probo.ActionReportGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
report, err := r.probo.Reports.Get(ctx, scope, id)
|
report, err := r.probo.Reports.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -304,7 +291,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.ProcessingActivityEntityType:
|
case coredata.ProcessingActivityEntityType:
|
||||||
action = probo.ActionProcessingActivityList
|
action = probo.ActionProcessingActivityList
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
processingActivity, err := r.probo.ProcessingActivities.Get(ctx, scope, id)
|
processingActivity, err := r.probo.ProcessingActivities.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -315,7 +302,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
case coredata.DataProtectionImpactAssessmentEntityType:
|
case coredata.DataProtectionImpactAssessmentEntityType:
|
||||||
// TODO: add action
|
// TODO: add action
|
||||||
// action = probo.ActionDataProtectionImpactAssessmentGet
|
// action = probo.ActionDataProtectionImpactAssessmentGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
dpia, err := r.probo.DataProtectionImpactAssessments.Get(ctx, scope, id)
|
dpia, err := r.probo.DataProtectionImpactAssessments.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -326,7 +313,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
case coredata.TransferImpactAssessmentEntityType:
|
case coredata.TransferImpactAssessmentEntityType:
|
||||||
// TODO: add action
|
// TODO: add action
|
||||||
//action = probo.ActionTransferImpactAssessmentGet
|
//action = probo.ActionTransferImpactAssessmentGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
tia, err := r.probo.TransferImpactAssessments.Get(ctx, scope, id)
|
tia, err := r.probo.TransferImpactAssessments.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -336,7 +323,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.TrustCenterEntityType:
|
case coredata.TrustCenterEntityType:
|
||||||
action = probo.ActionTrustCenterGet
|
action = probo.ActionTrustCenterGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
trustCenter, err := r.probo.TrustCenters.Get(ctx, scope, id)
|
trustCenter, err := r.probo.TrustCenters.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -354,7 +341,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.TrustCenterAccessEntityType:
|
case coredata.TrustCenterAccessEntityType:
|
||||||
action = probo.ActionTrustCenterAccessGet
|
action = probo.ActionTrustCenterAccessGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
trustCenterAccess, err := r.probo.TrustCenterAccesses.Get(ctx, scope, id)
|
trustCenterAccess, err := r.probo.TrustCenterAccesses.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -364,7 +351,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.RightsRequestEntityType:
|
case coredata.RightsRequestEntityType:
|
||||||
action = probo.ActionRightsRequestGet
|
action = probo.ActionRightsRequestGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
rightsRequest, err := r.probo.RightsRequests.Get(ctx, scope, id)
|
rightsRequest, err := r.probo.RightsRequests.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -374,7 +361,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.StatementOfApplicabilityEntityType:
|
case coredata.StatementOfApplicabilityEntityType:
|
||||||
action = probo.ActionStatementOfApplicabilityGet
|
action = probo.ActionStatementOfApplicabilityGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
statementOfApplicability, err := r.probo.StatementsOfApplicability.Get(ctx, scope, id)
|
statementOfApplicability, err := r.probo.StatementsOfApplicability.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -384,7 +371,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.WebhookSubscriptionEntityType:
|
case coredata.WebhookSubscriptionEntityType:
|
||||||
action = probo.ActionWebhookSubscriptionGet
|
action = probo.ActionWebhookSubscriptionGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
wc, err := r.probo.WebhookSubscriptions.Get(ctx, scope, id)
|
wc, err := r.probo.WebhookSubscriptions.Get(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -394,9 +381,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.AccessReviewCampaignEntityType:
|
case coredata.AccessReviewCampaignEntityType:
|
||||||
action = probo.ActionAccessReviewCampaignGet
|
action = probo.ActionAccessReviewCampaignGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
scope := coredata.NewScopeFromObjectID(id)
|
|
||||||
|
|
||||||
campaign, err := r.accessReview.Campaigns(scope).Get(ctx, id)
|
campaign, err := r.accessReview.Campaigns(scope).Get(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -406,9 +391,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.AccessSourceEntityType:
|
case coredata.AccessSourceEntityType:
|
||||||
action = probo.ActionAccessSourceGet
|
action = probo.ActionAccessSourceGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
scope := coredata.NewScopeFromObjectID(id)
|
|
||||||
|
|
||||||
source, err := r.accessReview.Sources(scope).Get(ctx, id)
|
source, err := r.accessReview.Sources(scope).Get(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -418,9 +401,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.AccessEntryEntityType:
|
case coredata.AccessEntryEntityType:
|
||||||
action = probo.ActionAccessEntryGet
|
action = probo.ActionAccessEntryGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
scope := coredata.NewScopeFromObjectID(id)
|
|
||||||
|
|
||||||
entry, err := r.accessReview.Entries(scope).Get(ctx, id)
|
entry, err := r.accessReview.Entries(scope).Get(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -430,9 +411,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.CookieBannerEntityType:
|
case coredata.CookieBannerEntityType:
|
||||||
action = probo.ActionCookieBannerGet
|
action = probo.ActionCookieBannerGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
scope := coredata.NewScopeFromObjectID(id)
|
|
||||||
|
|
||||||
banner, err := r.cookieBanner.GetCookieBanner(ctx, scope, id)
|
banner, err := r.cookieBanner.GetCookieBanner(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -442,9 +421,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.CookieCategoryEntityType:
|
case coredata.CookieCategoryEntityType:
|
||||||
action = probo.ActionCookieCategoryGet
|
action = probo.ActionCookieCategoryGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
scope := coredata.NewScopeFromObjectID(id)
|
|
||||||
|
|
||||||
category, err := r.cookieBanner.GetCookieCategory(ctx, scope, id)
|
category, err := r.cookieBanner.GetCookieCategory(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -454,9 +431,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.CookieConsentRecordEntityType:
|
case coredata.CookieConsentRecordEntityType:
|
||||||
action = probo.ActionCookieConsentRecordList
|
action = probo.ActionCookieConsentRecordList
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
scope := coredata.NewScopeFromObjectID(id)
|
|
||||||
|
|
||||||
record, err := r.cookieBanner.GetCookieConsentRecord(ctx, scope, id)
|
record, err := r.cookieBanner.GetCookieConsentRecord(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -478,9 +453,7 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
}
|
}
|
||||||
case coredata.CookieBannerVersionEntityType:
|
case coredata.CookieBannerVersionEntityType:
|
||||||
action = probo.ActionCookieBannerVersionGet
|
action = probo.ActionCookieBannerVersionGet
|
||||||
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
loadNode = func(ctx context.Context, scope *coredata.Scope, id gid.GID) (types.Node, error) {
|
||||||
scope := coredata.NewScopeFromObjectID(id)
|
|
||||||
|
|
||||||
version, err := r.cookieBanner.GetCookieBannerVersion(ctx, scope, id)
|
version, err := r.cookieBanner.GetCookieBannerVersion(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -497,11 +470,12 @@ func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := r.authorize(ctx, id, action); err != nil {
|
scope, err := r.authorize(ctx, id, action)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
node, err := loadNode(ctx, id)
|
node, err := loadNode(ctx, scope, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||||
return nil, gqlutils.NotFound(ctx, err)
|
return nil, gqlutils.NotFound(ctx, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user