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

46 lines
1.0 KiB
Go
Raw Normal View History

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.
package consoleql
2018-12-10 11:38:42 +00:00
import (
"time"
"github.com/graphql-go/graphql"
"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
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 {
User *console.User
2018-12-10 11:38:42 +00:00
JoinedAt time.Time
}