This repository has been archived by the owner on Nov 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmutation.go
121 lines (94 loc) · 1.91 KB
/
mutation.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
109
110
111
112
113
114
115
116
117
118
119
120
121
package main
import (
"context"
)
type rootMutation struct {
repository repository
}
type identity struct {
ID string
Version int
}
// CreateUser
func (m *rootMutation) CreateUser(ctx context.Context, args struct {
Input userInput
}) (*userOutput, error) {
user := &user{
FirstName: args.Input.FirstName,
LastName: args.Input.LastName,
Email: args.Input.Email,
Password: args.Input.Password,
Enabled: args.Input.Enabled,
Deleted: args.Input.Deleted,
}
err := m.repository.saveUser(ctx, user)
if err != nil {
return nil, err
}
return &userOutput{&userResolver{m.repository, user}}, nil
}
type userInput struct {
FirstName string
LastName string
Email string
Password string
Enabled bool
Deleted bool
}
type userOutput struct {
user *userResolver
}
func (o *userOutput) User() *userResolver {
return o.user
}
// UpdateUser
func (m *rootMutation) UpdateUser(args struct {
Identity identity
Input userInput
}) (*userOutput, error) {
return nil, nil
}
// CreateRole
func (m *rootMutation) CreateRole(args struct {
Input roleInput
}) (*roleOutput, error) {
return nil, nil
}
type roleInput struct {
Name string
}
type roleOutput struct {
role *roleResolver
}
func (o *roleOutput) Role() *roleResolver {
return o.role
}
// UpdateRole
func (m *rootMutation) UpdateRole(args struct {
Identity identity
Input roleInput
}) (*roleOutput, error) {
return nil, nil
}
// CreateAuthority
func (m *rootMutation) CreateAuthority(args struct {
Input authorityInput
}) (*authorityOutput, error) {
return nil, nil
}
type authorityInput struct {
Name string
}
type authorityOutput struct {
authority *authorityResolver
}
func (o *authorityOutput) Authority() *authorityResolver {
return o.authority
}
// UpdateAuthority
func (m *rootMutation) UpdateAuthority(args struct {
Identity identity
Input authorityInput
}) (*authorityOutput, error) {
return nil, nil
}