2019-01-24 16:26:36 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-12-10 11:38:42 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2019-01-15 13:03:24 +00:00
|
|
|
package consoleql
|
2018-12-10 11:38:42 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/graphql-go/graphql"
|
|
|
|
|
2019-01-15 13:03:24 +00:00
|
|
|
"storj.io/storj/satellite/console"
|
2018-12-10 11:38:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2019-01-24 16:26:36 +00:00
|
|
|
// ProjectMemberType is a graphql type name for project member
|
|
|
|
ProjectMemberType = "projectMember"
|
|
|
|
// FieldJoinedAt is a field name for joined at timestamp
|
|
|
|
FieldJoinedAt = "joinedAt"
|
2018-12-10 11:38:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// graphqlProjectMember creates projectMember type
|
2019-01-15 13:03:24 +00:00
|
|
|
func graphqlProjectMember(service *console.Service, types Types) *graphql.Object {
|
2018-12-10 11:38:42 +00:00
|
|
|
return graphql.NewObject(graphql.ObjectConfig{
|
2019-01-24 16:26:36 +00:00
|
|
|
Name: ProjectMemberType,
|
2018-12-10 11:38:42 +00:00
|
|
|
Fields: graphql.Fields{
|
2019-01-24 16:26:36 +00:00
|
|
|
UserType: &graphql.Field{
|
2018-12-10 11:38:42 +00:00
|
|
|
Type: types.User(),
|
|
|
|
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
|
|
|
|
member, _ := p.Source.(projectMember)
|
|
|
|
// company sub query expects pointer
|
|
|
|
return member.User, nil
|
|
|
|
},
|
|
|
|
},
|
2019-01-24 16:26:36 +00:00
|
|
|
FieldJoinedAt: &graphql.Field{
|
2018-12-10 11:38:42 +00:00
|
|
|
Type: graphql.DateTime,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// projectMember encapsulates User and joinedAt
|
|
|
|
type projectMember struct {
|
2019-01-15 13:03:24 +00:00
|
|
|
User *console.User
|
2018-12-10 11:38:42 +00:00
|
|
|
JoinedAt time.Time
|
|
|
|
}
|