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

#[derive(Debug, Clone, GraphQLObject)]
#[graphql(name = "LifecycleHookUpdateInfo")]
pub struct LifecycleHookUpdateInfoGraphQL {
    pub lifecycle_checks: Option<Vec<Json>>,
    pub extra_accounts: Option<Vec<ExtraAccountGraphQL>>,
    pub schema: Option<ExternalPluginAdapterSchemaGraphQL>,
}

impl From<crate::types::LifecycleHookUpdateInfo> for LifecycleHookUpdateInfoGraphQL {
    fn from(original: crate::types::LifecycleHookUpdateInfo) -> Self {
        Self {
            lifecycle_checks: original.lifecycle_checks.map(|v| {
                v.into_iter()
                    .map(|item| {
                        carbon_core::graphql::primitives::Json(
                            serde_json::to_value(item).unwrap_or(serde_json::Value::Null),
                        )
                    })
                    .collect()
            }),
            extra_accounts: original
                .extra_accounts
                .map(|v| v.into_iter().map(|item| item.into()).collect()),
            schema: original.schema.map(|v| v.into()),
        }
    }
}
