Skip to content

Commit

Permalink
chore(graphql): support query user by email
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Zhang <[email protected]>
  • Loading branch information
zwpaper committed Dec 3, 2024
1 parent e5096a9 commit 793ada4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions ee/tabby-schema/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ type Query {
me: UserSecured!
"List users, accessible for all login users."
users(after: String, before: String, first: Int, last: Int): UserConnection!
user(email: String): User!
invitations(after: String, before: String, first: Int, last: Int): InvitationConnection!
jobRuns(ids: [ID!], jobs: [String!], after: String, before: String, first: Int, last: Int): JobRunConnection!
jobRunStats(jobs: [String!]): JobStats!
Expand Down
14 changes: 14 additions & 0 deletions ee/tabby-schema/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,20 @@ impl Query {
.await
}

async fn user(ctx: &Context, email: Option<String>) -> Result<UserValue> {
check_user(ctx).await?;

if email.is_none() {
return Err(CoreError::InvalidInput(ValidationErrors::new()));
}

ctx.locator
.auth()
.get_user_by_email(email.unwrap().as_str())
.await
.map(UserValue::UserSecured)
}

async fn invitations(
ctx: &Context,
after: Option<String>,
Expand Down

0 comments on commit 793ada4

Please sign in to comment.