use {
carbon_core::graphql::primitives::{I64, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "MarketNode")]
pub struct MarketNodeGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub index: U8,
pub nonce: U8,
pub node_updates: Vec<I64>,
pub interest_update: I64,
}
impl TryFrom<crate::accounts::postgres::MarketNodeRow> for MarketNodeGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::MarketNodeRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
index: carbon_core::graphql::primitives::U8((*row.index) as u8),
nonce: carbon_core::graphql::primitives::U8((*row.nonce) as u8),
node_updates: row
.node_updates
.into_iter()
.map(carbon_core::graphql::primitives::I64)
.collect(),
interest_update: carbon_core::graphql::primitives::I64(row.interest_update),
})
}
}