/
gql_mutation_input.go
104 lines (94 loc) · 2.25 KB
/
gql_mutation_input.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
// Code generated by ent, DO NOT EDIT.
package ent
import (
"time"
"github.com/dsykes16/entpoc/ent/todo"
"github.com/rs/xid"
)
// CreateTodoInput represents a mutation input for creating todos.
type CreateTodoInput struct {
CreatedAt *time.Time
UpdatedAt *time.Time
Text string
Status todo.Status
Priority *int
ParentID *xid.ID
ChildIDs []xid.ID
}
// Mutate applies the CreateTodoInput on the TodoMutation builder.
func (i *CreateTodoInput) Mutate(m *TodoMutation) {
if v := i.CreatedAt; v != nil {
m.SetCreatedAt(*v)
}
if v := i.UpdatedAt; v != nil {
m.SetUpdatedAt(*v)
}
m.SetText(i.Text)
m.SetStatus(i.Status)
if v := i.Priority; v != nil {
m.SetPriority(*v)
}
if v := i.ParentID; v != nil {
m.SetParentID(*v)
}
if v := i.ChildIDs; len(v) > 0 {
m.AddChildIDs(v...)
}
}
// SetInput applies the change-set in the CreateTodoInput on the TodoCreate builder.
func (c *TodoCreate) SetInput(i CreateTodoInput) *TodoCreate {
i.Mutate(c.Mutation())
return c
}
// UpdateTodoInput represents a mutation input for updating todos.
type UpdateTodoInput struct {
UpdatedAt *time.Time
Text *string
Status *todo.Status
Priority *int
ClearParent bool
ParentID *xid.ID
ClearChildren bool
AddChildIDs []xid.ID
RemoveChildIDs []xid.ID
}
// Mutate applies the UpdateTodoInput on the TodoMutation builder.
func (i *UpdateTodoInput) Mutate(m *TodoMutation) {
if v := i.UpdatedAt; v != nil {
m.SetUpdatedAt(*v)
}
if v := i.Text; v != nil {
m.SetText(*v)
}
if v := i.Status; v != nil {
m.SetStatus(*v)
}
if v := i.Priority; v != nil {
m.SetPriority(*v)
}
if i.ClearParent {
m.ClearParent()
}
if v := i.ParentID; v != nil {
m.SetParentID(*v)
}
if i.ClearChildren {
m.ClearChildren()
}
if v := i.AddChildIDs; len(v) > 0 {
m.AddChildIDs(v...)
}
if v := i.RemoveChildIDs; len(v) > 0 {
m.RemoveChildIDs(v...)
}
}
// SetInput applies the change-set in the UpdateTodoInput on the TodoUpdate builder.
func (c *TodoUpdate) SetInput(i UpdateTodoInput) *TodoUpdate {
i.Mutate(c.Mutation())
return c
}
// SetInput applies the change-set in the UpdateTodoInput on the TodoUpdateOne builder.
func (c *TodoUpdateOne) SetInput(i UpdateTodoInput) *TodoUpdateOne {
i.Mutate(c.Mutation())
return c
}