added author
This commit is contained in:
parent
0b732b8205
commit
652e6ea553
@ -36,6 +36,22 @@ func createShema(repo repo.Repo) graphql.Schema {
|
|||||||
"score": &graphql.Field{
|
"score": &graphql.Field{
|
||||||
Type: graphql.NewNonNull(graphql.Int),
|
Type: graphql.NewNonNull(graphql.Int),
|
||||||
},
|
},
|
||||||
|
"author": &graphql.Field{
|
||||||
|
Type: graphql.NewNonNull(player),
|
||||||
|
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
|
||||||
|
game, ok := p.Source.(*model.Game)
|
||||||
|
if !ok {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
player, err := repo.GetPlayer(game.Author)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return player, nil
|
||||||
|
},
|
||||||
|
},
|
||||||
"team0player0": &graphql.Field{
|
"team0player0": &graphql.Field{
|
||||||
Type: graphql.NewNonNull(player),
|
Type: graphql.NewNonNull(player),
|
||||||
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
|
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user