Move Identity, Organization, Viewer, PageInfo, OrderDirection, CountryCode, OIDCProviderInfo, File, and ReauthenticationReason out of base.graphql into their own dedicated files across all three APIs. base.graphql now only contains directives, scalars, Node interface, Query type, and an empty Mutation type (required by Relay schemaExtensions). Entity files use extend type Mutation for their mutations. Signed-off-by: Émile Ré <emile@getprobo.com>
40 lines
1.2 KiB
Go
40 lines
1.2 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"
|
|
"time"
|
|
|
|
"go.gearno.de/kit/log"
|
|
"go.probo.inc/probo/pkg/probo"
|
|
"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"
|
|
)
|
|
|
|
// 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
|
|
}
|
|
|
|
// File returns schema.FileResolver implementation.
|
|
func (r *Resolver) File() schema.FileResolver { return &fileResolver{r} }
|
|
|
|
type fileResolver struct{ *Resolver }
|