forked from ent/contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
todo.resolvers.go
108 lines (89 loc) · 3.95 KB
/
todo.resolvers.go
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright 2019-present Facebook
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package todopulid
// 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.43
import (
"context"
"fmt"
"time"
"entgo.io/contrib/entgql"
"entgo.io/contrib/entgql/internal/todopulid/ent"
"entgo.io/contrib/entgql/internal/todopulid/ent/schema/pulid"
"entgo.io/contrib/entgql/internal/todopulid/ent/todo"
)
// TodosCount is the resolver for the todosCount field.
func (r *categoryResolver) TodosCount(ctx context.Context, obj *ent.Category) (*int, error) {
panic(fmt.Errorf("not implemented"))
}
// CreateCategory is the resolver for the createCategory field.
func (r *mutationResolver) CreateCategory(ctx context.Context, input ent.CreateCategoryInput) (*ent.Category, error) {
panic(fmt.Errorf("not implemented"))
}
// CreateTodo is the resolver for the createTodo field.
func (r *mutationResolver) CreateTodo(ctx context.Context, input ent.CreateTodoInput) (*ent.Todo, error) {
return ent.FromContext(ctx).Todo.
Create().
SetInput(input).
Save(ctx)
}
// UpdateTodo is the resolver for the updateTodo field.
func (r *mutationResolver) UpdateTodo(ctx context.Context, id pulid.ID, input ent.UpdateTodoInput) (*ent.Todo, error) {
panic(fmt.Errorf("not implemented"))
}
// ClearTodos is the resolver for the clearTodos field.
func (r *mutationResolver) ClearTodos(ctx context.Context) (int, error) {
client := ent.FromContext(ctx)
return client.Todo.
Delete().
Exec(ctx)
}
// UpdateFriendship is the resolver for the updateFriendship field.
func (r *mutationResolver) UpdateFriendship(ctx context.Context, id pulid.ID, input UpdateFriendshipInput) (*ent.Friendship, error) {
panic(fmt.Errorf("not implemented"))
}
// Ping is the resolver for the ping field.
func (r *queryResolver) Ping(ctx context.Context) (string, error) {
panic(fmt.Errorf("not implemented"))
}
// TodosWithJoins is the resolver for the todosWithJoins field.
func (r *queryResolver) TodosWithJoins(ctx context.Context, after *entgql.Cursor[pulid.ID], first *int, before *entgql.Cursor[pulid.ID], last *int, orderBy []*ent.TodoOrder, where *ent.TodoWhereInput) (*ent.TodoConnection, error) {
panic(fmt.Errorf("not implemented"))
}
// ExtendedField is the resolver for the extendedField field.
func (r *todoResolver) ExtendedField(ctx context.Context, obj *ent.Todo) (*string, error) {
panic(fmt.Errorf("not implemented"))
}
// CreateTodos is the resolver for the createTodos field.
func (r *createCategoryInputResolver) CreateTodos(ctx context.Context, obj *ent.CreateCategoryInput, data []*ent.CreateTodoInput) error {
panic(fmt.Errorf("not implemented"))
}
// CreatedToday is the resolver for the createdToday field.
func (r *todoWhereInputResolver) CreatedToday(ctx context.Context, obj *ent.TodoWhereInput, data *bool) error {
if data == nil {
return nil
}
startOfDay := time.Now().Truncate(24 * time.Hour)
endOfDay := startOfDay.Add(24*time.Hour - 1)
if *data {
obj.AddPredicates(todo.And(todo.CreatedAtGTE(startOfDay), todo.CreatedAtLTE(endOfDay)))
} else {
obj.AddPredicates(todo.Or(todo.CreatedAtLT(startOfDay), todo.CreatedAtGT(endOfDay)))
}
return nil
}
// Mutation returns MutationResolver implementation.
func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} }
type mutationResolver struct{ *Resolver }