step 4 : add company id, company name graphql

This commit is contained in:
sindhu
2024-01-18 16:59:47 +07:00
parent 87edd82ff7
commit c62764165d
4 changed files with 138 additions and 1 deletions

View File

@@ -59,6 +59,8 @@ type ComplexityRoot struct {
}
Staff struct {
CompanyID func(childComplexity int) int
CompanyName func(childComplexity int) int
CreatedAt func(childComplexity int) int
DisplayNameGoogleSignIn func(childComplexity int) int
Email func(childComplexity int) int
@@ -189,6 +191,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Query.Todos(childComplexity), true
case "Staff.company_id":
if e.complexity.Staff.CompanyID == nil {
break
}
return e.complexity.Staff.CompanyID(childComplexity), true
case "Staff.company_name":
if e.complexity.Staff.CompanyName == nil {
break
}
return e.complexity.Staff.CompanyName(childComplexity), true
case "Staff.created_at":
if e.complexity.Staff.CreatedAt == nil {
break
@@ -478,6 +494,8 @@ type Staff {
name: String!
email: String!
phone_number: String
company_id: ID!
company_name: String
is_active: String
is_login: String
token: String
@@ -781,6 +799,10 @@ func (ec *executionContext) fieldContext_Mutation_loginAttendance(ctx context.Co
return ec.fieldContext_Staff_email(ctx, field)
case "phone_number":
return ec.fieldContext_Staff_phone_number(ctx, field)
case "company_id":
return ec.fieldContext_Staff_company_id(ctx, field)
case "company_name":
return ec.fieldContext_Staff_company_name(ctx, field)
case "is_active":
return ec.fieldContext_Staff_is_active(ctx, field)
case "is_login":
@@ -918,6 +940,10 @@ func (ec *executionContext) fieldContext_Query_searchStaffByEmail(ctx context.Co
return ec.fieldContext_Staff_email(ctx, field)
case "phone_number":
return ec.fieldContext_Staff_phone_number(ctx, field)
case "company_id":
return ec.fieldContext_Staff_company_id(ctx, field)
case "company_name":
return ec.fieldContext_Staff_company_name(ctx, field)
case "is_active":
return ec.fieldContext_Staff_is_active(ctx, field)
case "is_login":
@@ -1001,6 +1027,10 @@ func (ec *executionContext) fieldContext_Query_staffGetByStaffId(ctx context.Con
return ec.fieldContext_Staff_email(ctx, field)
case "phone_number":
return ec.fieldContext_Staff_phone_number(ctx, field)
case "company_id":
return ec.fieldContext_Staff_company_id(ctx, field)
case "company_name":
return ec.fieldContext_Staff_company_name(ctx, field)
case "is_active":
return ec.fieldContext_Staff_is_active(ctx, field)
case "is_login":
@@ -1084,6 +1114,10 @@ func (ec *executionContext) fieldContext_Query_staffListBySearch(ctx context.Con
return ec.fieldContext_Staff_email(ctx, field)
case "phone_number":
return ec.fieldContext_Staff_phone_number(ctx, field)
case "company_id":
return ec.fieldContext_Staff_company_id(ctx, field)
case "company_name":
return ec.fieldContext_Staff_company_name(ctx, field)
case "is_active":
return ec.fieldContext_Staff_is_active(ctx, field)
case "is_login":
@@ -1464,6 +1498,91 @@ func (ec *executionContext) fieldContext_Staff_phone_number(ctx context.Context,
return fc, nil
}
func (ec *executionContext) _Staff_company_id(ctx context.Context, field graphql.CollectedField, obj *model.Staff) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Staff_company_id(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.CompanyID, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(string)
fc.Result = res
return ec.marshalNID2string(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Staff_company_id(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 ID does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Staff_company_name(ctx context.Context, field graphql.CollectedField, obj *model.Staff) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Staff_company_name(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.CompanyName, 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_company_name(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_is_active(ctx context.Context, field graphql.CollectedField, obj *model.Staff) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Staff_is_active(ctx, field)
if err != nil {
@@ -4189,6 +4308,13 @@ func (ec *executionContext) _Staff(ctx context.Context, sel ast.SelectionSet, ob
}
case "phone_number":
out.Values[i] = ec._Staff_phone_number(ctx, field, obj)
case "company_id":
out.Values[i] = ec._Staff_company_id(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "company_name":
out.Values[i] = ec._Staff_company_name(ctx, field, obj)
case "is_active":
out.Values[i] = ec._Staff_is_active(ctx, field, obj)
case "is_login":

View File

@@ -5,6 +5,8 @@ type Staff {
name: String!
email: String!
phone_number: String
company_id: ID!
company_name: String
is_active: String
is_login: String
token: String

View File

@@ -19,6 +19,8 @@ type Staff struct {
Name string `json:"name"`
Email string `json:"email"`
PhoneNumber *string `json:"phone_number,omitempty"`
CompanyID string `json:"company_id"`
CompanyName *string `json:"company_name,omitempty"`
IsActive *string `json:"is_active,omitempty"`
IsLogin *string `json:"is_login,omitempty"`
Token *string `json:"token,omitempty"`

View File

@@ -90,6 +90,8 @@ func (staff *Staff) LoginAttendance(email string, id_google_sign_in string) (*mo
M_StaffName,
M_StaffEmail,
M_StaffNoHp,
M_CompanyID,
M_CompanyName,
M_StaffIsActive,
M_StaffIsLogin,
M_StaffToken,
@@ -97,7 +99,10 @@ func (staff *Staff) LoginAttendance(email string, id_google_sign_in string) (*mo
M_StaffCreated,
M_StaffLastUpdated
FROM m_staff
WHERE M_StaffIsActive = 'Y'
join m_company
ON M_StaffM_CompanyID = M_CompanyID
AND M_CompanyIsActive = 'Y'
AND M_StaffIsActive = 'Y'
AND M_StaffIDGoogleSignIn = ?
AND M_StaffEmail = ?`
@@ -114,6 +119,8 @@ func (staff *Staff) LoginAttendance(email string, id_google_sign_in string) (*mo
&ret.Name,
&ret.Email,
&ret.PhoneNumber,
&ret.CompanyID,
&ret.CompanyName,
&ret.IsActive,
&ret.IsLogin,
&ret.Token,