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>
57 lines
1.8 KiB
Go
57 lines
1.8 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"
|
|
"fmt"
|
|
"time"
|
|
|
|
"go.probo.inc/probo/pkg/server/api/console/v1/schema"
|
|
"go.probo.inc/probo/pkg/server/api/console/v1/types"
|
|
)
|
|
|
|
// CertificateFileURL is the resolver for the certificateFileUrl field.
|
|
func (r *electronicSignatureResolver) CertificateFileURL(ctx context.Context, obj *types.ElectronicSignature) (*string, error) {
|
|
signature, err := r.esign.GetSignatureByID(ctx, obj.ID)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("cannot load signature: %w", err)
|
|
}
|
|
|
|
if signature.CertificateFileID == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
url, err := r.esign.GenerateCertificateFileURL(ctx, *signature.CertificateFileID, 1*time.Hour)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("cannot generate certificate file URL: %w", err)
|
|
}
|
|
|
|
return &url, nil
|
|
}
|
|
|
|
// Events is the resolver for the events field.
|
|
func (r *electronicSignatureResolver) Events(ctx context.Context, obj *types.ElectronicSignature) ([]*types.ElectronicSignatureEvent, error) {
|
|
events, err := r.esign.GetEventsBySignatureID(ctx, obj.ID)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("cannot load signature events: %w", err)
|
|
}
|
|
|
|
result := make([]*types.ElectronicSignatureEvent, len(events))
|
|
for i := range events {
|
|
result[i] = types.NewElectronicSignatureEvent(events[i])
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ElectronicSignature returns schema.ElectronicSignatureResolver implementation.
|
|
func (r *Resolver) ElectronicSignature() schema.ElectronicSignatureResolver {
|
|
return &electronicSignatureResolver{r}
|
|
}
|
|
|
|
type electronicSignatureResolver struct{ *Resolver }
|