use {
carbon_core::graphql::primitives::{Pubkey, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "ReferrerAlias")]
pub struct ReferrerAliasGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub nonce: U8,
pub alias: Vec<U8>,
pub referrer: Pubkey,
}
impl TryFrom<crate::accounts::postgres::ReferrerAliasRow> for ReferrerAliasGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::ReferrerAliasRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
nonce: carbon_core::graphql::primitives::U8((*row.nonce) as u8),
alias: row
.alias
.into_iter()
.map(carbon_core::graphql::primitives::U8)
.collect(),
referrer: carbon_core::graphql::primitives::Pubkey(row.referrer.0),
})
}
}