storj/satellite/console/consoleweb/consoleql/projectmember.go
Yehor Butko e38cf8f50d
Renaming and moving pkg/satellite to satellite/console (#1054)
* [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
2019-01-15 15:03:24 +02:00

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
}