Added create/delete group queries (#8)
This commit is contained in:
parent
2e952ea8cd
commit
64eac3d7c1
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
source: queries/src/lib.rs
|
||||
expression: operation.query
|
||||
---
|
||||
mutation CreateGroup($name: String!) {
|
||||
createGroup(name: $name) {
|
||||
id
|
||||
displayName
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
source: queries/src/lib.rs
|
||||
expression: operation.query
|
||||
---
|
||||
mutation DeleteGroup($id: Int!) {
|
||||
deleteGroup(groupId: $id) {
|
||||
ok
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user