Split each API's monolithic schema.graphql into per-coredata-model
files under graphql/ subdirectories. gqlgen's follow-schema layout
with {name}.resolvers.go template generates one resolver file per
schema file. Relay uses schema + schemaExtensions to load the split
files.
Connect API: 8 files (base, session, organization, profile,
personal_api_key, saml, scim, audit_log)
Trust API: 5 files (base, trust_center, auth, nda, mailing_list)
Console API: 25 files covering all domain entities
Types extended across files (Organization, Mutation, Viewer,
TrustCenter, Identity) are defined in base.graphql as required by
Relay's schemaExtensions.
Signed-off-by: Émile Ré <emile@getprobo.com>
566 lines
19 KiB
Go
566 lines
19 KiB
Go
package console_v1
|
|
|
|
// This file will be automatically regenerated based on the schema, any resolver
|
|
// implementations
|
|
// will be copied through when generating and any unknown code will be moved to the end.
|
|
// Code generated by github.com/99designs/gqlgen version v0.17.87
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"go.gearno.de/kit/log"
|
|
"go.probo.inc/probo/pkg/coredata"
|
|
"go.probo.inc/probo/pkg/gid"
|
|
"go.probo.inc/probo/pkg/iam"
|
|
"go.probo.inc/probo/pkg/page"
|
|
"go.probo.inc/probo/pkg/probo"
|
|
"go.probo.inc/probo/pkg/server/api/authn"
|
|
"go.probo.inc/probo/pkg/server/api/console/v1/schema"
|
|
"go.probo.inc/probo/pkg/server/api/console/v1/types"
|
|
"go.probo.inc/probo/pkg/server/gqlutils"
|
|
"go.probo.inc/probo/pkg/server/gqlutils/types/cursor"
|
|
"go.probo.inc/probo/pkg/validator"
|
|
)
|
|
|
|
// DownloadURL is the resolver for the downloadUrl field.
|
|
func (r *fileResolver) DownloadURL(ctx context.Context, obj *types.File) (string, error) {
|
|
if err := r.authorize(ctx, obj.ID, probo.ActionFileDownloadUrl); err != nil {
|
|
return "", err
|
|
}
|
|
|
|
prb := r.ProboService(ctx, obj.ID.TenantID())
|
|
|
|
downloadUrl, err := prb.Files.GenerateFileTempURL(ctx, obj.ID, 60*time.Second)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot generate download URL", log.Error(err))
|
|
return "", gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return downloadUrl, nil
|
|
}
|
|
|
|
// UpdateOrganizationContext is the resolver for the updateOrganizationContext field.
|
|
func (r *mutationResolver) UpdateOrganizationContext(ctx context.Context, input types.UpdateOrganizationContextInput) (*types.UpdateOrganizationContextPayload, error) {
|
|
if err := r.authorize(ctx, input.OrganizationID, probo.ActionOrganizationContextUpdate); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
|
|
|
req := probo.UpdateOrganizationContextRequest{
|
|
OrganizationID: input.OrganizationID,
|
|
Product: gqlutils.UnwrapOmittable(input.Product),
|
|
Architecture: gqlutils.UnwrapOmittable(input.Architecture),
|
|
Team: gqlutils.UnwrapOmittable(input.Team),
|
|
Processes: gqlutils.UnwrapOmittable(input.Processes),
|
|
Customers: gqlutils.UnwrapOmittable(input.Customers),
|
|
}
|
|
|
|
organizationContext, err := prb.Organizations.UpdateContext(ctx, req)
|
|
if err != nil {
|
|
if validationErrors, ok := errors.AsType[validator.ValidationErrors](err); ok {
|
|
return nil, gqlutils.InvalidValidationErrors(ctx, validationErrors)
|
|
}
|
|
r.logger.ErrorCtx(ctx, "cannot update organization context", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return &types.UpdateOrganizationContextPayload{
|
|
Context: types.NewOrganizationContext(organizationContext),
|
|
}, nil
|
|
}
|
|
|
|
// LogoURL is the resolver for the logoUrl field.
|
|
func (r *organizationResolver) LogoURL(ctx context.Context, obj *types.Organization) (*string, error) {
|
|
if err := r.authorize(ctx, obj.ID, probo.ActionOrganizationGetLogoUrl); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
prb := r.ProboService(ctx, obj.ID.TenantID())
|
|
|
|
logoURL, err := prb.Organizations.GenerateLogoURL(ctx, obj.ID, 1*time.Hour)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot generate logo url", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return logoURL, nil
|
|
}
|
|
|
|
// HorizontalLogoURL is the resolver for the horizontalLogoUrl field.
|
|
func (r *organizationResolver) HorizontalLogoURL(ctx context.Context, obj *types.Organization) (*string, error) {
|
|
if err := r.authorize(ctx, obj.ID, probo.ActionOrganizationGetHorizontalLogoUrl); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
prb := r.ProboService(ctx, obj.ID.TenantID())
|
|
|
|
horizontalLogoURL, err := prb.Organizations.GenerateHorizontalLogoURL(ctx, obj.ID, 1*time.Hour)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot generate horizontal logo url", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return horizontalLogoURL, nil
|
|
}
|
|
|
|
// Context is the resolver for the context field.
|
|
func (r *organizationResolver) Context(ctx context.Context, obj *types.Organization) (*types.OrganizationContext, error) {
|
|
if err := r.authorize(ctx, obj.ID, probo.ActionOrganizationContextGet); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
prb := r.ProboService(ctx, obj.ID.TenantID())
|
|
|
|
orgContext, err := prb.Organizations.GetContext(ctx, obj.ID)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot load organization context", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewOrganizationContext(orgContext), nil
|
|
}
|
|
|
|
// Profiles is the resolver for the profiles field.
|
|
func (r *organizationResolver) Profiles(ctx context.Context, obj *types.Organization, first *int, after *page.CursorKey, last *int, before *page.CursorKey, orderBy *types.ProfileOrderBy, filter *types.ProfileFilter) (*types.ProfileConnection, error) {
|
|
if err := r.authorize(ctx, obj.ID, iam.ActionMembershipProfileList); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if gqlutils.OnlyTotalCountSelected(ctx) {
|
|
return &types.ProfileConnection{
|
|
Resolver: r,
|
|
ParentID: obj.ID,
|
|
}, nil
|
|
}
|
|
|
|
filters := coredata.NewMembershipProfileFilter(nil).WithMembership()
|
|
if filter != nil {
|
|
filters = coredata.NewMembershipProfileFilter(filter.ExcludeContractEnded).WithMembership()
|
|
}
|
|
|
|
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)
|
|
}
|
|
|
|
cursor := cursor.NewCursor(first, after, last, before, pageOrderBy)
|
|
|
|
page, err := r.iam.OrganizationService.ListProfiles(ctx, obj.ID, cursor, filters)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot list profiles", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return types.NewProfileConnection(page, r, obj.ID, filters), nil
|
|
}
|
|
|
|
// MeasureCategories is the resolver for the measureCategories field.
|
|
func (r *organizationResolver) MeasureCategories(ctx context.Context, obj *types.Organization) ([]string, error) {
|
|
if err := r.authorize(ctx, obj.ID, probo.ActionMeasureList); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
prb := r.ProboService(ctx, obj.ID.TenantID())
|
|
|
|
categories, err := prb.Measures.ListDistinctCategoriesForOrganizationID(ctx, obj.ID)
|
|
if err != nil {
|
|
r.logger.ErrorCtx(ctx, "cannot list measure categories", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return categories, nil
|
|
}
|
|
|
|
// Permission is the resolver for the permission field.
|
|
func (r *organizationResolver) Permission(ctx context.Context, obj *types.Organization, action string) (bool, error) {
|
|
return r.Resolver.Permission(ctx, obj, action)
|
|
}
|
|
|
|
// Node is the resolver for the node field.
|
|
func (r *queryResolver) Node(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
var (
|
|
loadNode func(ctx context.Context, id gid.GID) (types.Node, error)
|
|
action string
|
|
prb = r.ProboService(ctx, id.TenantID())
|
|
)
|
|
|
|
switch id.EntityType() {
|
|
case coredata.OrganizationEntityType:
|
|
action = iam.ActionOrganizationGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
organization, err := prb.Organizations.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewOrganization(organization), nil
|
|
}
|
|
case coredata.VendorEntityType:
|
|
action = probo.ActionVendorGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
vendor, err := prb.Vendors.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewVendor(vendor), nil
|
|
}
|
|
case coredata.FrameworkEntityType:
|
|
action = probo.ActionFrameworkGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
framework, err := prb.Frameworks.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewFramework(framework), nil
|
|
}
|
|
case coredata.MeasureEntityType:
|
|
action = probo.ActionMeasureGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
measure, err := prb.Measures.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewMeasure(measure), nil
|
|
}
|
|
case coredata.TaskEntityType:
|
|
action = probo.ActionTaskGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
task, err := prb.Tasks.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewTask(task), nil
|
|
}
|
|
case coredata.EvidenceEntityType:
|
|
action = probo.ActionEvidenceList
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
evidence, err := prb.Evidences.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewEvidence(evidence), nil
|
|
}
|
|
case coredata.DocumentEntityType:
|
|
action = probo.ActionDocumentGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
document, err := prb.Documents.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewDocument(document), nil
|
|
}
|
|
case coredata.ControlEntityType:
|
|
action = probo.ActionControlList
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
control, err := prb.Controls.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewControl(control), nil
|
|
}
|
|
case coredata.RiskEntityType:
|
|
action = probo.ActionRiskGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
risk, err := prb.Risks.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewRisk(risk), nil
|
|
}
|
|
case coredata.VendorComplianceReportEntityType:
|
|
action = probo.ActionVendorComplianceReportGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
vendorComplianceReport, err := prb.VendorComplianceReports.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewVendorComplianceReport(vendorComplianceReport), nil
|
|
}
|
|
case coredata.VendorContactEntityType:
|
|
action = probo.ActionVendorContactGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
vendorContact, err := prb.VendorContacts.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewVendorContact(vendorContact), nil
|
|
}
|
|
case coredata.VendorServiceEntityType:
|
|
action = probo.ActionVendorServiceGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
vendorService, err := prb.VendorServices.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewVendorService(vendorService), nil
|
|
}
|
|
case coredata.DocumentVersionEntityType:
|
|
action = probo.ActionDocumentVersionList
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
documentVersion, err := prb.Documents.GetVersion(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewDocumentVersion(documentVersion), nil
|
|
}
|
|
case coredata.DocumentVersionSignatureEntityType:
|
|
action = probo.ActionDocumentVersionSignatureList
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
documentVersionSignature, err := prb.Documents.GetVersionSignature(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewDocumentVersionSignature(documentVersionSignature), nil
|
|
}
|
|
case coredata.AssetEntityType:
|
|
action = probo.ActionAssetList
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
asset, err := prb.Assets.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewAsset(asset), nil
|
|
}
|
|
case coredata.DatumEntityType:
|
|
action = probo.ActionDatumList
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
datum, err := prb.Data.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewDatum(datum), nil
|
|
}
|
|
case coredata.AuditEntityType:
|
|
action = probo.ActionAuditList
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
audit, err := prb.Audits.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewAudit(audit), nil
|
|
}
|
|
case coredata.FindingEntityType:
|
|
action = probo.ActionFindingList
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
finding, err := prb.Findings.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewFinding(finding), nil
|
|
}
|
|
case coredata.ObligationEntityType:
|
|
action = probo.ActionObligationList
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
obligation, err := prb.Obligations.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewObligation(obligation), nil
|
|
}
|
|
case coredata.ReportEntityType:
|
|
action = probo.ActionReportGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
report, err := prb.Reports.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewReport(report), nil
|
|
}
|
|
case coredata.ProcessingActivityEntityType:
|
|
action = probo.ActionProcessingActivityList
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
processingActivity, err := prb.ProcessingActivities.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewProcessingActivity(processingActivity), nil
|
|
}
|
|
case coredata.DataProtectionImpactAssessmentEntityType:
|
|
// TODO: add action
|
|
// action = probo.ActionDataProtectionImpactAssessmentGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
dpia, err := prb.DataProtectionImpactAssessments.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewDataProtectionImpactAssessment(dpia), nil
|
|
}
|
|
case coredata.TransferImpactAssessmentEntityType:
|
|
// TODO: add action
|
|
//action = probo.ActionTransferImpactAssessmentGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
tia, err := prb.TransferImpactAssessments.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewTransferImpactAssessment(tia), nil
|
|
}
|
|
case coredata.SnapshotEntityType:
|
|
action = probo.ActionSnapshotList
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
snapshot, err := prb.Snapshots.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewSnapshot(snapshot), nil
|
|
}
|
|
case coredata.TrustCenterEntityType:
|
|
action = probo.ActionTrustCenterGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
trustCenter, err := prb.TrustCenters.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var file *coredata.File
|
|
if trustCenter.NonDisclosureAgreementFileID != nil {
|
|
file, err = prb.Files.Get(ctx, *trustCenter.NonDisclosureAgreementFileID)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("cannot get NDA file: %w", err)
|
|
}
|
|
}
|
|
|
|
return types.NewTrustCenter(trustCenter, file), nil
|
|
}
|
|
case coredata.TrustCenterAccessEntityType:
|
|
action = probo.ActionTrustCenterAccessGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
trustCenterAccess, err := prb.TrustCenterAccesses.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewTrustCenterAccess(trustCenterAccess), nil
|
|
}
|
|
case coredata.MeetingEntityType:
|
|
action = probo.ActionMeetingGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
meeting, err := prb.Meetings.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewMeeting(meeting), nil
|
|
}
|
|
case coredata.RightsRequestEntityType:
|
|
action = probo.ActionRightsRequestGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
rightsRequest, err := prb.RightsRequests.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewRightsRequest(rightsRequest), nil
|
|
}
|
|
case coredata.StatementOfApplicabilityEntityType:
|
|
action = probo.ActionStatementOfApplicabilityGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
statementOfApplicability, err := prb.StatementsOfApplicability.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewStatementOfApplicability(statementOfApplicability), nil
|
|
}
|
|
case coredata.WebhookSubscriptionEntityType:
|
|
action = probo.ActionWebhookSubscriptionGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
wc, err := prb.WebhookSubscriptions.Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewWebhookSubscription(wc), nil
|
|
}
|
|
case coredata.AccessReviewCampaignEntityType:
|
|
action = probo.ActionAccessReviewCampaignGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
scope := coredata.NewScopeFromObjectID(id)
|
|
campaign, err := r.accessReview.Campaigns(scope).Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewAccessReviewCampaign(campaign), nil
|
|
}
|
|
case coredata.AccessSourceEntityType:
|
|
action = probo.ActionAccessSourceGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
scope := coredata.NewScopeFromObjectID(id)
|
|
source, err := r.accessReview.Sources(scope).Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewAccessSource(source), nil
|
|
}
|
|
case coredata.AccessEntryEntityType:
|
|
action = probo.ActionAccessEntryGet
|
|
loadNode = func(ctx context.Context, id gid.GID) (types.Node, error) {
|
|
scope := coredata.NewScopeFromObjectID(id)
|
|
entry, err := r.accessReview.Entries(scope).Get(ctx, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return types.NewAccessEntry(entry), nil
|
|
}
|
|
default:
|
|
}
|
|
|
|
if err := r.authorize(ctx, id, action); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
node, err := loadNode(ctx, id)
|
|
if err != nil {
|
|
if errors.Is(err, coredata.ErrResourceNotFound) {
|
|
return nil, gqlutils.NotFound(ctx, err)
|
|
}
|
|
|
|
r.logger.ErrorCtx(ctx, "cannot load node", log.Error(err))
|
|
return nil, gqlutils.Internal(ctx)
|
|
}
|
|
|
|
return node, nil
|
|
}
|
|
|
|
// Viewer is the resolver for the viewer field.
|
|
func (r *queryResolver) Viewer(ctx context.Context) (*types.Viewer, error) {
|
|
identity := authn.IdentityFromContext(ctx)
|
|
|
|
session := authn.SessionFromContext(ctx)
|
|
apiKey := authn.APIKeyFromContext(ctx)
|
|
|
|
var viewerID gid.GID
|
|
if session != nil {
|
|
viewerID = session.ID
|
|
} else if apiKey != nil {
|
|
viewerID = apiKey.ID
|
|
} else {
|
|
viewerID = identity.ID
|
|
}
|
|
|
|
return &types.Viewer{ID: viewerID}, nil
|
|
}
|
|
|
|
// File returns schema.FileResolver implementation.
|
|
func (r *Resolver) File() schema.FileResolver { return &fileResolver{r} }
|
|
|
|
// Mutation returns schema.MutationResolver implementation.
|
|
func (r *Resolver) Mutation() schema.MutationResolver { return &mutationResolver{r} }
|
|
|
|
// Organization returns schema.OrganizationResolver implementation.
|
|
func (r *Resolver) Organization() schema.OrganizationResolver { return &organizationResolver{r} }
|
|
|
|
// Query returns schema.QueryResolver implementation.
|
|
func (r *Resolver) Query() schema.QueryResolver { return &queryResolver{r} }
|
|
|
|
// Viewer returns schema.ViewerResolver implementation.
|
|
func (r *Resolver) Viewer() schema.ViewerResolver { return &viewerResolver{r} }
|
|
|
|
type fileResolver struct{ *Resolver }
|
|
type mutationResolver struct{ *Resolver }
|
|
type organizationResolver struct{ *Resolver }
|
|
type queryResolver struct{ *Resolver }
|
|
type viewerResolver struct{ *Resolver }
|