graphvent/gql_query.go

39 lines
774 B
Go

2023-07-21 15:16:35 -06:00
package graphvent
import (
"github.com/graphql-go/graphql"
)
var GQLQuerySelf = &graphql.Field{
Type: GQLTypeGQLThread.Type,
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
2023-07-21 18:51:42 -06:00
ctx, err := GetResolveContext(p)
if err != nil {
return nil, err
}
2023-07-21 15:16:35 -06:00
2023-07-21 18:51:42 -06:00
err = ctx.Server.Allowed("enumerate", "self", ctx.User)
if err != nil {
return nil, err
}
2023-07-21 15:16:35 -06:00
2023-07-21 18:51:42 -06:00
return ctx.Server, nil
},
}
var GQLQueryUser = &graphql.Field{
Type: GQLTypeUser.Type,
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
2023-07-21 18:51:42 -06:00
ctx, err := GetResolveContext(p)
if err != nil {
return nil, err
}
2023-07-21 15:16:35 -06:00
2023-07-21 18:51:42 -06:00
err = ctx.User.Allowed("enumerate", "self", ctx.User)
if err != nil {
return nil, err
2023-07-21 15:16:35 -06:00
}
2023-07-21 18:51:42 -06:00
return ctx.User, nil
},
2023-07-21 15:16:35 -06:00
}