use {
crate::types::graphql::{KeyGraphQL, ReservationV1GraphQL},
carbon_core::graphql::primitives::{Pubkey, U64},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "ReservationListV1")]
pub struct ReservationListV1GraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub key: KeyGraphQL,
pub master_edition: Pubkey,
pub supply_snapshot: Option<U64>,
pub reservations: Vec<ReservationV1GraphQL>,
}
impl TryFrom<crate::accounts::postgres::ReservationListV1Row> for ReservationListV1GraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::ReservationListV1Row) -> 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(),
})
}
}