graphql_composition/
result.rs1use crate::{
2 Diagnostics,
3 diagnostics::{CompositeSchemasErrorCode, CompositeSchemasSourceSchemaValidationErrorCode},
4 federated_graph::FederatedGraph,
5};
6
7pub struct CompositionResult {
9 pub(crate) federated_graph: Option<FederatedGraph>,
10 pub(crate) diagnostics: Diagnostics,
11}
12
13impl CompositionResult {
14 #[doc(hidden)]
16 pub fn warnings_are_fatal(mut self) -> Self {
17 if self.diagnostics.iter().any(|diagnostic| {
18 diagnostic.composite_schemas_error_code()
19 != Some(CompositeSchemasErrorCode::SourceSchema(
20 CompositeSchemasSourceSchemaValidationErrorCode::LookupReturnsNonNullableType,
21 ))
22 }) {
23 self.federated_graph = None;
24 }
25 self
26 }
27 pub fn into_result(self) -> Result<FederatedGraph, Diagnostics> {
32 if let Some(federated_graph) = self.federated_graph {
33 Ok(federated_graph)
34 } else {
35 Err(self.diagnostics)
37 }
38 }
39
40 pub fn diagnostics(&self) -> &Diagnostics {
42 &self.diagnostics
43 }
44}