Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(account): search user by email only #41

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions account/accountusecase/accountinteractor/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions account/accountusecase/accountproxy/operations.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ query UserByIDs($id: [ID!]!) {
}
}

query SearchUser($nameOrEmail: String!) {
searchUser(nameOrEmail: $nameOrEmail) {
query SearchUser($email: String!) {
searchUser(email: $email) {
...FragmentUser
}
}
Expand Down
4 changes: 2 additions & 2 deletions account/accountusecase/accountproxy/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion account/user.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ input DeleteMeInput {

extend type Query {
me: Me
searchUser(nameOrEmail: String!): User
searchUser(email: String!): User
}

type UserPayload {
Expand Down
Loading