use {
crate::types::graphql::{ExternalRegistryRecordGraphQL, KeyGraphQL, RegistryRecordGraphQL},
juniper::GraphQLObject,
};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "PluginRegistryV1")]
pub struct PluginRegistryV1GraphQL {
pub account_metadata: crate::accounts::graphql::AccountMetadataGraphQL,
pub key: KeyGraphQL,
pub registry: Vec<RegistryRecordGraphQL>,
pub external_registry: Vec<ExternalRegistryRecordGraphQL>,
}
impl TryFrom<crate::accounts::postgres::PluginRegistryV1Row> for PluginRegistryV1GraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::accounts::postgres::PluginRegistryV1Row) -> Result<Self, Self::Error> {
Ok(Self {
account_metadata: row.account_metadata.into(),
key: row.key.0.into(),
registry: row.registry.0.into_iter().map(|item| item.into()).collect(),
external_registry: row
.external_registry
.0
.into_iter()
.map(|item| item.into())
.collect(),
})
}
}