storj/satellite/console/consoleweb/consoleql/user.go

79 lines
2.0 KiB
Go
Raw Normal View History

2019-01-24 16:26:36 +00:00
// 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.
2019-01-24 16:26:36 +00:00
UserType = "user"
// UserInputType is a graphql type for user input.
2019-01-24 16:26:36 +00:00
UserInputType = "userInput"
// FieldID is a field name for id.
2019-01-24 16:26:36 +00:00
FieldID = "id"
// FieldEmail is a field name for email.
2019-01-24 16:26:36 +00:00
FieldEmail = "email"
// FieldPassword is a field name for password.
2019-01-24 16:26:36 +00:00
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.
2019-01-24 16:26:36 +00:00
FieldCreatedAt = "createdAt"
)
// base graphql config for user.
func baseUserConfig() graphql.ObjectConfig {
return graphql.ObjectConfig{
2019-01-24 16:26:36 +00:00
Name: UserType,
Fields: graphql.Fields{
2019-01-24 16:26:36 +00:00
FieldID: &graphql.Field{
Type: graphql.String,
},
2019-01-24 16:26:36 +00:00
FieldEmail: &graphql.Field{
Type: graphql.String,
},
FieldFullName: &graphql.Field{
Type: graphql.String,
},
FieldShortName: &graphql.Field{
Type: graphql.String,
},
2019-01-24 16:26:36 +00:00
FieldCreatedAt: &graphql.Field{
Type: graphql.DateTime,
},
},
}
}
// graphqlUser creates *graphql.Object type representation of satellite.User.
func graphqlUser() *graphql.Object {
// TODO: simplify
return graphql.NewObject(baseUserConfig())
}
2018-11-21 15:51:43 +00:00
// graphqlUserInput creates graphql.InputObject type needed to register/update satellite.User.
2019-04-04 15:56:20 +01:00
func graphqlUserInput() *graphql.InputObject {
2018-11-21 15:51:43 +00:00
return graphql.NewInputObject(graphql.InputObjectConfig{
2019-01-24 16:26:36 +00:00
Name: UserInputType,
2018-11-21 15:51:43 +00:00
Fields: graphql.InputObjectConfigFieldMap{
2019-01-24 16:26:36 +00:00
FieldEmail: &graphql.InputObjectFieldConfig{
2018-11-21 15:51:43 +00:00
Type: graphql.String,
},
FieldFullName: &graphql.InputObjectFieldConfig{
2018-11-21 15:51:43 +00:00
Type: graphql.String,
},
FieldShortName: &graphql.InputObjectFieldConfig{
2018-11-21 15:51:43 +00:00
Type: graphql.String,
},
2019-01-24 16:26:36 +00:00
FieldPassword: &graphql.InputObjectFieldConfig{
2018-11-21 15:51:43 +00:00
Type: graphql.String,
},
},
})
}