Added create/delete group queries (#8)

This commit is contained in:
Dreaded_X 2025-03-22 03:53:01 +01:00
parent 2e952ea8cd
commit 64eac3d7c1
Signed by: Dreaded_X
GPG Key ID: FA5F485356B0D2D4
3 changed files with 57 additions and 0 deletions

View File

@ -86,6 +86,30 @@ pub struct GetGroups {
pub groups: Vec<Group>,
}
#[derive(cynic::QueryVariables, Debug)]
pub struct CreateGroupVariables<'a> {
pub name: &'a str,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Mutation", variables = "CreateGroupVariables")]
pub struct CreateGroup {
#[arguments(name: $name)]
pub create_group: Group,
}
#[derive(cynic::QueryVariables, Debug)]
pub struct DeleteGroupVariables {
pub id: i32,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Mutation", variables = "DeleteGroupVariables")]
pub struct DeleteGroup {
#[arguments(groupId: $id)]
pub delete_group: Success,
}
#[cfg(test)]
mod tests {
use cynic::{MutationBuilder, QueryBuilder};
@ -139,4 +163,18 @@ mod tests {
insta::assert_snapshot!(operation.query);
}
#[test]
fn create_group_gql_output() {
let operation = CreateGroup::build(CreateGroupVariables { name: "group" });
insta::assert_snapshot!(operation.query);
}
#[test]
fn delete_group_gql_output() {
let operation = DeleteGroup::build(DeleteGroupVariables { id: 0 });
insta::assert_snapshot!(operation.query);
}
}

View File

@ -0,0 +1,10 @@
---
source: queries/src/lib.rs
expression: operation.query
---
mutation CreateGroup($name: String!) {
createGroup(name: $name) {
id
displayName
}
}

View File

@ -0,0 +1,9 @@
---
source: queries/src/lib.rs
expression: operation.query
---
mutation DeleteGroup($id: Int!) {
deleteGroup(groupId: $id) {
ok
}
}