diff --git a/src/models/customer.rs b/src/models/customer.rs index 5e600f5..ce38caf 100644 --- a/src/models/customer.rs +++ b/src/models/customer.rs @@ -1,7 +1,6 @@ use chrono::NaiveDateTime; use diesel::prelude::*; -use juniper::FieldResult; -use juniper_codegen::{object, GraphQLInputObject}; +use juniper_codegen::GraphQLInputObject; use crate::models::{Invoice, Task}; use crate::schema::customers; @@ -54,19 +53,6 @@ impl Customer { } } -#[object(Context = DbConn)] -impl Customer { - /// Returns the invoices billed to the customer. - fn invoices(&self, context: &DbConn) -> FieldResult> { - self.invoices(context).map_err(Into::into) - } - - /// Returns the project/tasks associated with the customer. - fn tasks(&self, context: &DbConn) -> FieldResult> { - self.tasks(context).map_err(Into::into) - } -} - /// The new customer model /// /// This model represents a new customer that can be inserted into the database. @@ -94,3 +80,22 @@ pub struct NewCustomer { /// Flag whether the customer requires time specificaions pub time_specification: bool, } + +mod graphql { + use super::{Customer, DbConn, Invoice, Task}; + + use juniper::{object, FieldResult}; + + #[object(Context = DbConn)] + impl Customer { + /// Returns the invoices billed to the customer. + fn invoices(&self, context: &DbConn) -> FieldResult> { + self.invoices(context).map_err(Into::into) + } + + /// Returns the project/tasks associated with the customer. + fn tasks(&self, context: &DbConn) -> FieldResult> { + self.tasks(context).map_err(Into::into) + } + } +}