-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest.go
More file actions
51 lines (38 loc) · 1.53 KB
/
test.go
File metadata and controls
51 lines (38 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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"
"fmt"
pkgContext "github.com/oursky/likedao/pkg/context"
servererrors "github.com/oursky/likedao/pkg/errors"
"github.com/oursky/likedao/pkg/models"
)
func (r *mutationResolver) CreateTest(ctx context.Context, input models.CreateTest) (*models.Test, error) {
res, err := pkgContext.GetMutatorsFromCtx(ctx).Test.CreateTest(input.String, input.Int)
if err != nil {
return nil, servererrors.MutationError.NewError(ctx, fmt.Sprintf("failed to create test: %v", err))
}
return res, nil
}
func (r *queryResolver) QueryTestByID(ctx context.Context, id models.NodeID) (*models.Test, error) {
res, err := pkgContext.GetDataLoadersFromCtx(ctx).Test.Load(id.ID)
if err != nil {
return nil, servererrors.QueryError.NewError(ctx, fmt.Sprintf("failed to query test: %v", err))
}
return res, nil
}
func (r *queryResolver) QueryTestsByIDs(ctx context.Context, ids []models.NodeID) ([]*models.Test, error) {
objIds := models.ExtractObjectIDs(ids)
res, errs := pkgContext.GetDataLoadersFromCtx(ctx).Test.LoadAll(objIds)
for _, err := range errs {
if err != nil {
return nil, servererrors.QueryError.NewError(ctx, fmt.Sprintf("failed to query tests: %v", err))
}
}
return res, nil
}
func (r *queryResolver) Me(ctx context.Context) (string, error) {
address := pkgContext.GetAuthedUserAddress(ctx)
return address, nil
}