graphql_composition/
result.rs1use crate::{Diagnostics, diagnostics::CompositeSchemasErrorCode, federated_graph::FederatedGraph};
2
3pub struct CompositionResult {
5 pub(crate) federated_graph: Option<FederatedGraph>,
6 pub(crate) diagnostics: Diagnostics,
7}
8
9impl CompositionResult {
10 #[doc(hidden)]
12 pub fn warnings_are_fatal(mut self) -> Self {
13 if self.diagnostics.iter().any(|diagnostic| {
14 diagnostic.composite_shemas_error_code() != Some(CompositeSchemasErrorCode::LookupReturnsNonNullableType)
15 }) {
16 self.federated_graph = None;
17 }
18 self
19 }
20 pub fn into_result(self) -> Result<FederatedGraph, Diagnostics> {
25 if let Some(federated_graph) = self.federated_graph {
26 Ok(federated_graph)
27 } else {
28 Err(self.diagnostics)
30 }
31 }
32
33 pub fn diagnostics(&self) -> &Diagnostics {
35 &self.diagnostics
36 }
37}