use {juniper::GraphQLObject, serde_json};
#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "Disable")]
pub struct DisableGraphQL {
pub instruction_metadata: crate::instructions::graphql::InstructionMetadataGraphQL,
pub disable_create_pool: bool,
pub disable_deposit: bool,
pub disable_withdraw: bool,
pub disable_buy: bool,
pub disable_sell: bool,
pub accounts: carbon_core::graphql::primitives::Json,
}
impl TryFrom<crate::instructions::postgres::DisableRow> for DisableGraphQL {
type Error = carbon_core::error::Error;
fn try_from(row: crate::instructions::postgres::DisableRow) -> Result<Self, Self::Error> {
Ok(Self {
instruction_metadata: row.instruction_metadata.into(),
disable_create_pool: row.disable_create_pool,
disable_deposit: row.disable_deposit,
disable_withdraw: row.disable_withdraw,
disable_buy: row.disable_buy,
disable_sell: row.disable_sell,
accounts: carbon_core::graphql::primitives::Json(
serde_json::to_value(&row.accounts.0)
.map_err(|e| carbon_core::error::Error::Custom(e.to_string()))?,
),
})
}
}