Implement additionalGroups functionality (#2)
This commit is contained in:
@@ -43,6 +43,19 @@ pub struct AddUserToGroup {
|
||||
pub add_user_to_group: Success,
|
||||
}
|
||||
|
||||
#[derive(cynic::QueryVariables, Debug)]
|
||||
pub struct RemoveUserFromGroupVariables<'a> {
|
||||
pub group: i32,
|
||||
pub username: &'a str,
|
||||
}
|
||||
|
||||
#[derive(cynic::QueryFragment, Debug)]
|
||||
#[cynic(graphql_type = "Mutation", variables = "RemoveUserFromGroupVariables")]
|
||||
pub struct RemoveUserFromGroup {
|
||||
#[arguments(groupId: $group, userId: $username)]
|
||||
pub remove_user_from_group: Success,
|
||||
}
|
||||
|
||||
#[derive(cynic::QueryVariables, Debug)]
|
||||
pub struct GetUserVariables<'a> {
|
||||
pub username: &'a str,
|
||||
@@ -64,6 +77,13 @@ pub struct User {
|
||||
#[derive(cynic::QueryFragment, Debug)]
|
||||
pub struct Group {
|
||||
pub id: i32,
|
||||
pub display_name: String,
|
||||
}
|
||||
|
||||
#[derive(cynic::QueryFragment, Debug)]
|
||||
#[cynic(graphql_type = "Query")]
|
||||
pub struct GetGroups {
|
||||
pub groups: Vec<Group>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -96,10 +116,27 @@ mod tests {
|
||||
insta::assert_snapshot!(operation.query);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_user_from_group_gql_output() {
|
||||
let operation = RemoveUserFromGroup::build(RemoveUserFromGroupVariables {
|
||||
group: 3,
|
||||
username: "user",
|
||||
});
|
||||
|
||||
insta::assert_snapshot!(operation.query);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_user_gql_output() {
|
||||
let operation = GetUser::build(GetUserVariables { username: "user" });
|
||||
|
||||
insta::assert_snapshot!(operation.query);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_groups_gql_output() {
|
||||
let operation = GetGroups::build(());
|
||||
|
||||
insta::assert_snapshot!(operation.query);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ mutation CreateUser($username: String!) {
|
||||
id
|
||||
groups {
|
||||
id
|
||||
displayName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
source: queries/src/lib.rs
|
||||
expression: operation.query
|
||||
---
|
||||
query GetGroups {
|
||||
groups {
|
||||
id
|
||||
displayName
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ query GetUser($username: String!) {
|
||||
id
|
||||
groups {
|
||||
id
|
||||
displayName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
source: queries/src/lib.rs
|
||||
expression: operation.query
|
||||
---
|
||||
mutation RemoveUserFromGroup($group: Int!, $username: String!) {
|
||||
removeUserFromGroup(groupId: $group, userId: $username) {
|
||||
ok
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user