use {
crate::types::graphql::{KeyGraphQL, ReservationGraphQL},
carbon_core::graphql::primitives::{Pubkey, U64},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "ReservationListV2")]
pub struct ReservationListV2GraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub key: KeyGraphQL,
pub master_edition: Pubkey,
pub supply_snapshot: Option<U64>,
pub reservations: Vec<ReservationGraphQL>,
pub total_reservation_spots: U64,
pub current_reservation_spots: U64,
}
impl TryFrom<crate::accounts::postgres::ReservationListV2Row> for ReservationListV2GraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::ReservationListV2Row) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
key: row.key.0.into(),
master_edition: carbon_core::graphql::primitives::Pubkey(row.master_edition.0),
supply_snapshot: row
.supply_snapshot
.map(|v| carbon_core::graphql::primitives::U64(*v)),
reservations: row
.reservations
.0
.into_iter()
.map(|item| item.into())
.collect(),
total_reservation_spots: carbon_core::graphql::primitives::U64(
*row.total_reservation_spots,
),
current_reservation_spots: carbon_core::graphql::primitives::U64(
*row.current_reservation_spots,
),
})
}
}