graphql: Add a method to look up a group's details
This commit is contained in:
committed by
nitnelave
parent
9e9129aa3a
commit
65780ae0fe
@@ -139,6 +139,17 @@ impl<Handler: BackendHandler + Sync> Query<Handler> {
|
||||
.await
|
||||
.map(|v| v.into_iter().map(Into::into).collect())?)
|
||||
}
|
||||
|
||||
async fn group(context: &Context<Handler>, group_id: i32) -> FieldResult<Group<Handler>> {
|
||||
if !context.validation_result.is_admin {
|
||||
return Err("Unauthorized access to group data".into());
|
||||
}
|
||||
Ok(context
|
||||
.handler
|
||||
.get_group_details(GroupId(group_id))
|
||||
.await
|
||||
.map(Into::into)?)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||
|
||||
@@ -29,6 +29,7 @@ mockall::mock! {
|
||||
async fn list_users(&self, filters: Option<RequestFilter>) -> DomainResult<Vec<User>>;
|
||||
async fn list_groups(&self) -> DomainResult<Vec<Group>>;
|
||||
async fn get_user_details(&self, user_id: &str) -> DomainResult<User>;
|
||||
async fn get_group_details(&self, group_id: GroupId) -> DomainResult<GroupIdAndName>;
|
||||
async fn get_user_groups(&self, user: &str) -> DomainResult<HashSet<GroupIdAndName>>;
|
||||
async fn create_user(&self, request: CreateUserRequest) -> DomainResult<()>;
|
||||
async fn update_user(&self, request: UpdateUserRequest) -> DomainResult<()>;
|
||||
|
||||
Reference in New Issue
Block a user