e38cf8f50d
* [WIP] V3-853 Merge the satellite DB into the master database * Removing consoleDB from satelliteDB * Fixing tests for satellite/console * fixing linter * sorting imports in satellite/console * fixing console config * fixing linter
45 lines
950 B
Go
45 lines
950 B
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package consoleql
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/graphql-go/graphql"
|
|
|
|
"storj.io/storj/satellite/console"
|
|
)
|
|
|
|
const (
|
|
projectMemberType = "projectMember"
|
|
|
|
fieldJoinedAt = "joinedAt"
|
|
)
|
|
|
|
// graphqlProjectMember creates projectMember type
|
|
func graphqlProjectMember(service *console.Service, types Types) *graphql.Object {
|
|
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
|
|
JoinedAt time.Time
|
|
}
|