Renamed id to username for better dx

This commit is contained in:
2025-03-19 02:49:05 +01:00
parent f3010febdc
commit fac8e44b24
6 changed files with 25 additions and 25 deletions

View File

@@ -3,13 +3,13 @@ pub(crate) mod schema {}
#[derive(cynic::QueryVariables, Debug)]
pub struct DeleteUserVariables<'a> {
pub id: &'a str,
pub username: &'a str,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Mutation", variables = "DeleteUserVariables")]
pub struct DeleteUser {
#[arguments(userId: $id)]
#[arguments(userId: $username)]
pub delete_user: Success,
}
@@ -20,38 +20,38 @@ pub struct Success {
#[derive(cynic::QueryVariables, Debug)]
pub struct CreateUserVariables<'a> {
pub id: &'a str,
pub username: &'a str,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Mutation", variables = "CreateUserVariables")]
pub struct CreateUser {
#[arguments(user: { email: $id, id: $id })]
#[arguments(user: { email: $username, id: $username })]
pub create_user: User,
}
#[derive(cynic::QueryVariables, Debug)]
pub struct AddUserToGroupVariables<'a> {
pub group: i32,
pub id: &'a str,
pub username: &'a str,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Mutation", variables = "AddUserToGroupVariables")]
pub struct AddUserToGroup {
#[arguments(groupId: $group, userId: $id)]
#[arguments(groupId: $group, userId: $username)]
pub add_user_to_group: Success,
}
#[derive(cynic::QueryVariables, Debug)]
pub struct GetUserVariables<'a> {
pub id: &'a str,
pub username: &'a str,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query", variables = "GetUserVariables")]
pub struct GetUser {
#[arguments(userId: $id)]
#[arguments(userId: $username)]
pub user: User,
}
@@ -74,14 +74,14 @@ mod tests {
#[test]
fn delete_user_gql_output() {
let operation = DeleteUser::build(DeleteUserVariables { id: "user" });
let operation = DeleteUser::build(DeleteUserVariables { username: "user" });
insta::assert_snapshot!(operation.query);
}
#[test]
fn create_user_gql_output() {
let operation = CreateUser::build(CreateUserVariables { id: "user" });
let operation = CreateUser::build(CreateUserVariables { username: "user" });
insta::assert_snapshot!(operation.query);
}
@@ -89,7 +89,7 @@ mod tests {
#[test]
fn add_user_to_group_gql_output() {
let operation = AddUserToGroup::build(AddUserToGroupVariables {
id: "user",
username: "user",
group: 3,
});
@@ -98,7 +98,7 @@ mod tests {
#[test]
fn get_user_gql_output() {
let operation = GetUser::build(GetUserVariables { id: "user" });
let operation = GetUser::build(GetUserVariables { username: "user" });
insta::assert_snapshot!(operation.query);
}