package resolvers // 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. import ( "context" "git.aiterp.net/stufflog/server/graph/graphcore" "git.aiterp.net/stufflog/server/graph/loaders" "git.aiterp.net/stufflog/server/internal/xlerrors" "git.aiterp.net/stufflog/server/models" ) func (r *projectResolver) Issues(ctx context.Context, obj *models.Project, filter *graphcore.ProjectIssueFilter) ([]*models.Issue, error) { if filter == nil { filter = &graphcore.ProjectIssueFilter{} } return r.Database.Issues().List(ctx, models.IssueFilter{ ProjectIDs: []string{obj.ID}, AssigneeIDs: filter.AssigneeIds, Search: filter.Search, MinStage: filter.MinStage, MaxStage: filter.MaxStage, Limit: filter.Limit, }) } func (r *projectResolver) Permissions(ctx context.Context, obj *models.Project) ([]*models.ProjectPermission, error) { if perm, err := r.Auth.ProjectPermission(ctx, *obj); err != nil || !perm.CanManagePermissions() { return nil, xlerrors.PermissionDenied } return r.Database.Projects().ListPermissions(ctx, *obj) } func (r *projectResolver) UserPermissions(ctx context.Context, obj *models.Project) (*models.ProjectPermission, error) { return r.Auth.ProjectPermission(ctx, *obj) } func (r *projectResolver) Statuses(ctx context.Context, obj *models.Project, filter *models.ProjectStatusFilter) ([]*models.ProjectStatus, error) { if filter == nil { filter = &models.ProjectStatusFilter{} } filter.ProjectID = &obj.ID return r.Database.ProjectStatuses().List(ctx, *filter) } func (r *projectResolver) Activities(ctx context.Context, obj *models.Project) ([]*models.Activity, error) { return r.Database.Activities().List(ctx, models.ActivityFilter{ProjectIDs: []string{obj.ID}}) } func (r *projectPermissionResolver) User(ctx context.Context, obj *models.ProjectPermission) (*models.User, error) { return loaders.UserLoaderFromContext(ctx).Load(obj.UserID) } // Project returns graphcore.ProjectResolver implementation. func (r *Resolver) Project() graphcore.ProjectResolver { return &projectResolver{r} } // ProjectPermission returns graphcore.ProjectPermissionResolver implementation. func (r *Resolver) ProjectPermission() graphcore.ProjectPermissionResolver { return &projectPermissionResolver{r} } type projectResolver struct{ *Resolver } type projectPermissionResolver struct{ *Resolver }