step 3 : login absensi fix, return graphql staff

This commit is contained in:
sindhu
2024-01-18 16:42:23 +07:00
parent 2bd8da63fc
commit 87edd82ff7
10 changed files with 200 additions and 128 deletions

View File

@@ -48,7 +48,7 @@ type DirectiveRoot struct {
type ComplexityRoot struct {
Mutation struct {
CreateTodo func(childComplexity int, input model.NewTodo) int
LoginAttendance func(childComplexity int, email string, idGoogleSignIn string, publickey string) int
LoginAttendance func(childComplexity int, email string, idGoogleSignIn string) int
}
Query struct {
@@ -62,6 +62,7 @@ type ComplexityRoot struct {
CreatedAt func(childComplexity int) int
DisplayNameGoogleSignIn func(childComplexity int) int
Email func(childComplexity int) int
Expired func(childComplexity int) int
IDGoogleSignIn func(childComplexity int) int
IsActive func(childComplexity int) int
IsLogin func(childComplexity int) int
@@ -93,7 +94,7 @@ type ComplexityRoot struct {
type MutationResolver interface {
CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error)
LoginAttendance(ctx context.Context, email string, idGoogleSignIn string, publickey string) (*model.Staff, error)
LoginAttendance(ctx context.Context, email string, idGoogleSignIn string) (*model.Staff, error)
}
type QueryResolver interface {
Todos(ctx context.Context) ([]*model.Todo, error)
@@ -143,7 +144,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return 0, false
}
return e.complexity.Mutation.LoginAttendance(childComplexity, args["email"].(string), args["id_google_sign_in"].(string), args["publickey"].(string)), true
return e.complexity.Mutation.LoginAttendance(childComplexity, args["email"].(string), args["id_google_sign_in"].(string)), true
case "Query.searchStaffByEmail":
if e.complexity.Query.SearchStaffByEmail == nil {
@@ -209,6 +210,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Staff.Email(childComplexity), true
case "Staff.expired":
if e.complexity.Staff.Expired == nil {
break
}
return e.complexity.Staff.Expired(childComplexity), true
case "Staff.id_google_sign_in":
if e.complexity.Staff.IDGoogleSignIn == nil {
break
@@ -471,8 +479,9 @@ type Staff {
email: String!
phone_number: String
is_active: String
is_login: Boolean
is_login: String
token: String
expired: String
id_google_sign_in: String!
display_name_google_sign_in: String
created_at: String
@@ -494,7 +503,7 @@ extend type Query {
# mutation untuk perubahan data
extend type Mutation {
loginAttendance(email:String!, id_google_sign_in:String!, publickey:String!) : Staff!
loginAttendance(email:String!, id_google_sign_in:String!) : Staff!
}`, BuiltIn: false},
}
var parsedSchema = gqlparser.MustLoadSchema(sources...)
@@ -539,15 +548,6 @@ func (ec *executionContext) field_Mutation_loginAttendance_args(ctx context.Cont
}
}
args["id_google_sign_in"] = arg1
var arg2 string
if tmp, ok := rawArgs["publickey"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publickey"))
arg2, err = ec.unmarshalNString2string(ctx, tmp)
if err != nil {
return nil, err
}
}
args["publickey"] = arg2
return args, nil
}
@@ -746,7 +746,7 @@ func (ec *executionContext) _Mutation_loginAttendance(ctx context.Context, field
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.resolvers.Mutation().LoginAttendance(rctx, fc.Args["email"].(string), fc.Args["id_google_sign_in"].(string), fc.Args["publickey"].(string))
return ec.resolvers.Mutation().LoginAttendance(rctx, fc.Args["email"].(string), fc.Args["id_google_sign_in"].(string))
})
if err != nil {
ec.Error(ctx, err)
@@ -787,6 +787,8 @@ func (ec *executionContext) fieldContext_Mutation_loginAttendance(ctx context.Co
return ec.fieldContext_Staff_is_login(ctx, field)
case "token":
return ec.fieldContext_Staff_token(ctx, field)
case "expired":
return ec.fieldContext_Staff_expired(ctx, field)
case "id_google_sign_in":
return ec.fieldContext_Staff_id_google_sign_in(ctx, field)
case "display_name_google_sign_in":
@@ -922,6 +924,8 @@ func (ec *executionContext) fieldContext_Query_searchStaffByEmail(ctx context.Co
return ec.fieldContext_Staff_is_login(ctx, field)
case "token":
return ec.fieldContext_Staff_token(ctx, field)
case "expired":
return ec.fieldContext_Staff_expired(ctx, field)
case "id_google_sign_in":
return ec.fieldContext_Staff_id_google_sign_in(ctx, field)
case "display_name_google_sign_in":
@@ -1003,6 +1007,8 @@ func (ec *executionContext) fieldContext_Query_staffGetByStaffId(ctx context.Con
return ec.fieldContext_Staff_is_login(ctx, field)
case "token":
return ec.fieldContext_Staff_token(ctx, field)
case "expired":
return ec.fieldContext_Staff_expired(ctx, field)
case "id_google_sign_in":
return ec.fieldContext_Staff_id_google_sign_in(ctx, field)
case "display_name_google_sign_in":
@@ -1084,6 +1090,8 @@ func (ec *executionContext) fieldContext_Query_staffListBySearch(ctx context.Con
return ec.fieldContext_Staff_is_login(ctx, field)
case "token":
return ec.fieldContext_Staff_token(ctx, field)
case "expired":
return ec.fieldContext_Staff_expired(ctx, field)
case "id_google_sign_in":
return ec.fieldContext_Staff_id_google_sign_in(ctx, field)
case "display_name_google_sign_in":
@@ -1520,9 +1528,9 @@ func (ec *executionContext) _Staff_is_login(ctx context.Context, field graphql.C
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*bool)
res := resTmp.(*string)
fc.Result = res
return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res)
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Staff_is_login(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
@@ -1532,7 +1540,7 @@ func (ec *executionContext) fieldContext_Staff_is_login(ctx context.Context, fie
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Boolean does not have child fields")
return nil, errors.New("field of type String does not have child fields")
},
}
return fc, nil
@@ -1579,6 +1587,47 @@ func (ec *executionContext) fieldContext_Staff_token(ctx context.Context, field
return fc, nil
}
func (ec *executionContext) _Staff_expired(ctx context.Context, field graphql.CollectedField, obj *model.Staff) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Staff_expired(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Expired, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*string)
fc.Result = res
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Staff_expired(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Staff",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Staff_id_google_sign_in(ctx context.Context, field graphql.CollectedField, obj *model.Staff) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Staff_id_google_sign_in(ctx, field)
if err != nil {
@@ -4146,6 +4195,8 @@ func (ec *executionContext) _Staff(ctx context.Context, sel ast.SelectionSet, ob
out.Values[i] = ec._Staff_is_login(ctx, field, obj)
case "token":
out.Values[i] = ec._Staff_token(ctx, field, obj)
case "expired":
out.Values[i] = ec._Staff_expired(ctx, field, obj)
case "id_google_sign_in":
out.Values[i] = ec._Staff_id_google_sign_in(ctx, field, obj)
if out.Values[i] == graphql.Null {