//! This code was AUTOGENERATED using the Codama library.
use {
    crate::types::graphql::{
        AuthorityGraphQL, ExternalPluginAdapterSchemaGraphQL, ExtraAccountGraphQL,
    },
    carbon_core::graphql::primitives::Pubkey,
    juniper::GraphQLObject,
};

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "LinkedLifecycleHook")]
pub struct LinkedLifecycleHookGraphQL {
    pub hooked_program: Pubkey,
    pub extra_accounts: Option<Vec<ExtraAccountGraphQL>>,
    pub data_authority: Option<AuthorityGraphQL>,
    pub schema: ExternalPluginAdapterSchemaGraphQL,
}

impl From<crate::types::LinkedLifecycleHook> for LinkedLifecycleHookGraphQL {
    fn from(original: crate::types::LinkedLifecycleHook) -> Self {
        Self {
            hooked_program: carbon_core::graphql::primitives::Pubkey(original.hooked_program),
            extra_accounts: original
                .extra_accounts
                .map(|v| v.into_iter().map(|item| item.into()).collect()),
            data_authority: original.data_authority.map(|v| v.into()),
            schema: original.schema.into(),
        }
    }
}
