-
Notifications
You must be signed in to change notification settings - Fork 390
/
user.go
86 lines (80 loc) · 2.2 KB
/
user.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
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package consoleql
import (
"github.com/graphql-go/graphql"
)
const (
// UserType is a graphql type for user.
UserType = "user"
// UserInputType is a graphql type for user input.
UserInputType = "userInput"
// FieldID is a field name for id.
FieldID = "id"
// FieldEmail is a field name for email.
FieldEmail = "email"
// FieldPassword is a field name for password.
FieldPassword = "password"
// FieldFullName is a field name for "first name".
FieldFullName = "fullName"
// FieldShortName is a field name for "last name".
FieldShortName = "shortName"
// FieldCreatedAt is a field name for created at timestamp.
FieldCreatedAt = "createdAt"
// FieldPartnerID is a field name for partnerID.
FieldPartnerID = "partnerId"
)
// base graphql config for user.
func baseUserConfig() graphql.ObjectConfig {
return graphql.ObjectConfig{
Name: UserType,
Fields: graphql.Fields{
FieldID: &graphql.Field{
Type: graphql.String,
},
FieldEmail: &graphql.Field{
Type: graphql.String,
},
FieldFullName: &graphql.Field{
Type: graphql.String,
},
FieldShortName: &graphql.Field{
Type: graphql.String,
},
FieldCreatedAt: &graphql.Field{
Type: graphql.DateTime,
},
FieldPartnerID: &graphql.Field{
Type: graphql.String,
},
},
}
}
// graphqlUser creates *graphql.Object type representation of satellite.User.
func graphqlUser() *graphql.Object {
// TODO: simplify
return graphql.NewObject(baseUserConfig())
}
// graphqlUserInput creates graphql.InputObject type needed to register/update satellite.User.
func graphqlUserInput() *graphql.InputObject {
return graphql.NewInputObject(graphql.InputObjectConfig{
Name: UserInputType,
Fields: graphql.InputObjectConfigFieldMap{
FieldEmail: &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
FieldFullName: &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
FieldShortName: &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
FieldPassword: &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
FieldPartnerID: &graphql.InputObjectFieldConfig{
Type: graphql.String,
},
},
})
}