use {
crate::types::graphql::KeyGraphQL, carbon_core::graphql::primitives::U8, juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "HashedAssetV1")]
pub struct HashedAssetV1GraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub key: KeyGraphQL,
pub hash: Vec<U8>,
}
impl TryFrom<crate::accounts::postgres::HashedAssetV1Row> for HashedAssetV1GraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::HashedAssetV1Row) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
key: row.key.0.into(),
hash: row
.hash
.into_iter()
.map(carbon_core::graphql::primitives::U8)
.collect(),
})
}
}