Skip to content

Commit

Permalink
domain/gql: adds and wires CurrentUserType
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-ramon committed May 3, 2024
1 parent 8075bb9 commit 38a6af4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions domain/gql/fields/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var PingField = &graphql.Field{

var CurrentUserField = &graphql.Field{
Name: "CurrentUser",
Type: types.UserType,
Type: types.CurrentUserType,
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
srvs, err := servicesFromResolveParams(p)
if err != nil {
Expand All @@ -43,7 +43,7 @@ var CurrentUserField = &graphql.Field{
}

var AuthUserField = &graphql.Field{
Type: types.UserType,
Type: types.CurrentUserType,
Description: "Authenticates and authorizes an user.",
Args: graphql.FieldConfigArgument{
"username": &graphql.ArgumentConfig{
Expand Down
18 changes: 16 additions & 2 deletions domain/gql/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"github.com/graphql-go/graphql"
)

var UserType = graphql.NewObject(graphql.ObjectConfig{
Name: "UserType",
var CurrentUserType = graphql.NewObject(graphql.ObjectConfig{
Name: "CurrentUserType",
Fields: graphql.Fields{
"id": &graphql.Field{
Description: "The id of the user.",
Expand All @@ -21,3 +21,17 @@ var UserType = graphql.NewObject(graphql.ObjectConfig{
},
},
})

var UserType = graphql.NewObject(graphql.ObjectConfig{
Name: "UserType",
Fields: graphql.Fields{
"id": &graphql.Field{
Description: "The id of the user.",
Type: graphql.String,
},
"username": &graphql.Field{
Description: "The username of the user.",
Type: graphql.String,
},
},
})

0 comments on commit 38a6af4

Please sign in to comment.