Skip to content

Commit

Permalink
Abacus: expose "cat dates" in GraphQL
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtnzlml authored and kodiakhq[bot] committed Dec 24, 2021
1 parent 4c72b89 commit dc6c86b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/abacus/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @generated SignedSource<<42e0dce29c56ba2596a34977bba81d8d>>
# @generated SignedSource<<cb53033398b922d633f12636b7cbec91>>

enum PriceSortDirection {
LOW_TO_HIGH
Expand Down Expand Up @@ -49,6 +49,12 @@ type CatInfo {
description: String!
"Order in which the cat was admitted to KOCHKA Café."
order: Int!
"When was the cat adopted (when it leaved KOCHKA Café)."
dateOfAdoption: String
"When was the cat dewormed for the last time."
dateOfDeworming: String
"When was the cat castrated."
dateOfCastration: String
}

type POSMutation {
Expand Down
18 changes: 18 additions & 0 deletions src/abacus/src/cats/dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ pub struct CatInfo {
name: String,
description: String,
order: i32,
date_adoption: Option<String>,
date_deworming: Option<String>,
date_castration: Option<String>,
}

#[juniper::graphql_object]
Expand All @@ -28,6 +31,21 @@ impl CatInfo {
fn order(&self) -> i32 {
self.order.to_owned()
}

/// When was the cat adopted (when it leaved KOCHKA Café).
fn date_of_adoption(&self) -> Option<String> {
self.date_adoption.to_owned()
}

/// When was the cat dewormed for the last time.
fn date_of_deworming(&self) -> Option<String> {
self.date_deworming.to_owned()
}

/// When was the cat castrated.
fn date_of_castration(&self) -> Option<String> {
self.date_castration.to_owned()
}
}

pub(in crate::cats) async fn list_all_cats(pool: &ConnectionPool) -> anyhow::Result<Vec<CatInfo>> {
Expand Down

0 comments on commit dc6c86b

Please sign in to comment.