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

45 lines
950 B
Go
Raw Normal View History

2018-12-10 11:38:42 +00:00
// Copyright (C) 2018 Storj Labs, Inc.
// 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 (
projectMemberType = "projectMember"
fieldJoinedAt = "joinedAt"
)
// 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{
Name: projectMemberType,
Fields: graphql.Fields{
userType: &graphql.Field{
Type: types.User(),
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
member, _ := p.Source.(projectMember)
// company sub query expects pointer
return member.User, nil
},
},
fieldJoinedAt: &graphql.Field{
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
}