From 0a73c1a3c8c1669ba2ed21b0c856274534b229d6 Mon Sep 17 00:00:00 2001 From: json singh <20891087+jashanbhullar@users.noreply.github.com> Date: Tue, 11 Jun 2024 19:38:12 +0530 Subject: [PATCH 1/2] Search user by email, not by name: --- account/accountusecase/accountinteractor/user.go | 8 ++++---- account/accountusecase/accountproxy/user.go | 4 ++-- account/user.graphql | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/account/accountusecase/accountinteractor/user.go b/account/accountusecase/accountinteractor/user.go index 6a62678..3b3bedd 100644 --- a/account/accountusecase/accountinteractor/user.go +++ b/account/accountusecase/accountinteractor/user.go @@ -70,8 +70,8 @@ func (i *User) FetchBySub(ctx context.Context, sub string) (*user.User, error) { return i.query.FetchBySub(ctx, sub) } -func (i *User) SearchUser(ctx context.Context, nameOrEmail string) (*user.Simple, error) { - return i.query.SearchUser(ctx, nameOrEmail) +func (i *User) SearchUser(ctx context.Context, email string) (*user.Simple, error) { + return i.query.SearchUser(ctx, email) } func (i *User) GetUserByCredentials(ctx context.Context, inp accountinterfaces.GetUserByCredentials) (u *user.User, err error) { @@ -407,9 +407,9 @@ func (q *UserQuery) FetchBySub(ctx context.Context, sub string) (*user.User, err return nil, rerror.ErrNotFound } -func (q *UserQuery) SearchUser(ctx context.Context, nameOrEmail string) (*user.Simple, error) { +func (q *UserQuery) SearchUser(ctx context.Context, email string) (*user.Simple, error) { for _, r := range q.repos { - u, err := r.FindByNameOrEmail(ctx, nameOrEmail) + u, err := r.FindByEmail(ctx, email) if errors.Is(err, rerror.ErrNotFound) { continue } diff --git a/account/accountusecase/accountproxy/user.go b/account/accountusecase/accountproxy/user.go index ad08020..9276ad9 100644 --- a/account/accountusecase/accountproxy/user.go +++ b/account/accountusecase/accountproxy/user.go @@ -104,8 +104,8 @@ func (u *User) RemoveMyAuth(ctx context.Context, auth string, op *accountusecase return MeToUser(res.RemoveMyAuth.Me.FragmentMe) } -func (u *User) SearchUser(ctx context.Context, nameOrEmail string) (*user.Simple, error) { - res, err := SearchUser(ctx, u.gql, nameOrEmail) +func (u *User) SearchUser(ctx context.Context, email string) (*user.Simple, error) { + res, err := SearchUser(ctx, u.gql, email) if err != nil { return nil, err } diff --git a/account/user.graphql b/account/user.graphql index 97d1c4c..3acf562 100644 --- a/account/user.graphql +++ b/account/user.graphql @@ -82,7 +82,7 @@ input DeleteMeInput { extend type Query { me: Me - searchUser(nameOrEmail: String!): User + searchUser(email: String!): User } type UserPayload { From f4b189007a9e9170cd1e4986d8954f79ef0bb39e Mon Sep 17 00:00:00 2001 From: json singh <20891087+jashanbhullar@users.noreply.github.com> Date: Tue, 11 Jun 2024 19:42:15 +0530 Subject: [PATCH 2/2] - one place left --- account/accountusecase/accountproxy/operations.graphql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/account/accountusecase/accountproxy/operations.graphql b/account/accountusecase/accountproxy/operations.graphql index e856eb9..ed2d604 100644 --- a/account/accountusecase/accountproxy/operations.graphql +++ b/account/accountusecase/accountproxy/operations.graphql @@ -30,8 +30,8 @@ query UserByIDs($id: [ID!]!) { } } -query SearchUser($nameOrEmail: String!) { - searchUser(nameOrEmail: $nameOrEmail) { +query SearchUser($email: String!) { + searchUser(email: $email) { ...FragmentUser } }