fn updateExpense(context: &Context, input: UpdateExpenseInput) -> Result<bool, GraphQLError> {
        let UpdateExpenseInput {
            expense_id,
            name,
            amount,
        } = input;
        // Check input validity
        let expense_id = match uuid::Uuid::parse_str(expense_id.as_str()) {
            Err(e) => return Err(GraphQLError::InvalidId),
            Ok(u) => u,
        };

        let expense = repositories::UpdateExpense {
            id: expense_id,
            name,
            amount,
        };
        repositories::ExpenseRepository::update_one(&expense, &context.db_pool)
            .map_err(GraphQLError::InternalServerError)
            .map(|_| true)
    }
// FIXME: Extract domain and repository logic to own module
/// Update an expense. Idempotent mutation.
/// This is a user context dependant mutation.
Extract domain and repository logic to own module
Update an expense. Idempotent mutation.
This is a user context dependant mutation.
Extract domain and repository logic to own module Update an expense . Idempotent mutation . This is a user context dependant mutation .
fn updateExpense(context: &Context, input: UpdateExpenseInput) -> Result<bool, GraphQLError> {
        let UpdateExpenseInput {
            expense_id,
            name,
            amount,
        } = input;
        // Check input validity
        let expense_id = match uuid::Uuid::parse_str(expense_id.as_str()) {
            Err(e) => return Err(GraphQLError::InvalidId),
            Ok(u) => u,
        };
        let expense = repositories::UpdateExpense {
            id: expense_id,
            name,
            amount,
        };
        repositories::ExpenseRepository::update_one(&expense, &context.db_pool)
            .map_err(GraphQLError::InternalServerError)
            .map(|_| true)
    }
fn updateExpense ( context : & Context , input : UpdateExpenseInput ) -> Result < bool , GraphQLError > { let UpdateExpenseInput { expense_id , name , amount , } = input ; // Check input validity let expense_id = match uuid :: Uuid :: parse_str ( expense_id . as_str ( ) ) { Err ( e ) => return Err ( GraphQLError :: InvalidId ) , Ok ( u ) => u , } ; let expense = repositories :: UpdateExpense { id : expense_id , name , amount , } ; repositories :: ExpenseRepository :: update_one ( & expense , & context . db_pool ) . map_err ( GraphQLError :: InternalServerError ) . map ( | _ | true ) }
FIXME: Extract domain and repository logic to own module
Update an expense.
FIXME : Extract domain and repository logic to own module Update an expense .
context
&Context
input
UpdateExpenseInput
context
&Context
input
UpdateExpenseInput