use {
carbon_core::graphql::primitives::{Pubkey, U8},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "ReferrerName")]
pub struct ReferrerNameGraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub authority: Pubkey,
pub user: Pubkey,
pub user_stats: Pubkey,
pub name: Vec<U8>,
}
impl TryFrom<crate::accounts::postgres::ReferrerNameRow> for ReferrerNameGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::ReferrerNameRow) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
authority: carbon_core::graphql::primitives::Pubkey(row.authority.0),
user: carbon_core::graphql::primitives::Pubkey(row.user.0),
user_stats: carbon_core::graphql::primitives::Pubkey(row.user_stats.0),
name: row
.name
.into_iter()
.map(carbon_core::graphql::primitives::U8)
.collect(),
})
}
}