use crate::{
Diagnostics,
diagnostics::{CompositeSchemasErrorCode, CompositeSchemasSourceSchemaValidationErrorCode},
federated_graph::FederatedGraph,
};
pub struct CompositionResult {
pub(crate) federated_graph: Option<FederatedGraph>,
pub(crate) diagnostics: Diagnostics,
}
impl CompositionResult {
#[doc(hidden)]
pub fn warnings_are_fatal(mut self) -> Self {
if self.diagnostics.iter().any(|diagnostic| {
diagnostic.composite_schemas_error_code()
!= Some(CompositeSchemasErrorCode::SourceSchema(
CompositeSchemasSourceSchemaValidationErrorCode::LookupReturnsNonNullableType,
))
}) {
self.federated_graph = None;
}
self
}
pub fn into_result(self) -> Result<FederatedGraph, Diagnostics> {
if let Some(federated_graph) = self.federated_graph {
Ok(federated_graph)
} else {
Err(self.diagnostics)
}
}
pub fn diagnostics(&self) -> &Diagnostics {
&self.diagnostics
}
}