board_operations.go

 1package resolvers
 2
 3import (
 4	"context"
 5	"fmt"
 6
 7	"github.com/git-bug/git-bug/api/graphql/graph"
 8	"github.com/git-bug/git-bug/api/graphql/models"
 9	"github.com/git-bug/git-bug/entities/board"
10)
11
12var _ graph.BoardAddItemDraftOperationResolver = boardAddItemDraftOperationResolver{}
13
14type boardAddItemDraftOperationResolver struct{}
15
16func (boardAddItemDraftOperationResolver) Author(ctx context.Context, obj *board.AddItemDraftOperation) (models.IdentityWrapper, error) {
17	return models.NewLoadedIdentity(obj.Author()), nil
18}
19
20var _ graph.BoardAddItemEntityOperationResolver = boardAddItemEntityOperationResolver{}
21
22type boardAddItemEntityOperationResolver struct{}
23
24func (boardAddItemEntityOperationResolver) Author(ctx context.Context, obj *board.AddItemEntityOperation) (models.IdentityWrapper, error) {
25	return models.NewLoadedIdentity(obj.Author()), nil
26}
27
28func (boardAddItemEntityOperationResolver) EntityType(ctx context.Context, obj *board.AddItemEntityOperation) (models.BoardItemEntityType, error) {
29	switch obj.EntityType {
30	case board.EntityTypeBug:
31		return models.BoardItemEntityTypeBug, nil
32	default:
33		return "", fmt.Errorf("unknown entity type: %s", obj.EntityType)
34	}
35}
36
37var _ graph.BoardCreateOperationResolver = boardCreateOperationResolver{}
38
39type boardCreateOperationResolver struct{}
40
41func (boardCreateOperationResolver) Author(ctx context.Context, obj *board.CreateOperation) (models.IdentityWrapper, error) {
42	return models.NewLoadedIdentity(obj.Author()), nil
43}
44
45var _ graph.BoardSetDescriptionOperationResolver = boardSetDescriptionOperationResolver{}
46
47type boardSetDescriptionOperationResolver struct{}
48
49func (boardSetDescriptionOperationResolver) Author(ctx context.Context, obj *board.SetDescriptionOperation) (models.IdentityWrapper, error) {
50	return models.NewLoadedIdentity(obj.Author()), nil
51}
52
53var _ graph.BoardSetTitleOperationResolver = boardSetTitleOperationResolver{}
54
55type boardSetTitleOperationResolver struct{}
56
57func (boardSetTitleOperationResolver) Author(ctx context.Context, obj *board.SetTitleOperation) (models.IdentityWrapper, error) {
58	return models.NewLoadedIdentity(obj.Author()), nil
59}