graphql_composition/
result.rs1use crate::{Diagnostics, federated_graph::FederatedGraph};
2
3pub struct CompositionResult {
5 pub(crate) federated_graph: Option<FederatedGraph>,
6 pub(crate) diagnostics: Diagnostics,
7}
8
9impl CompositionResult {
10 pub fn warnings_are_fatal(mut self) -> Self {
12 if !self.diagnostics.is_empty() {
13 self.federated_graph = None;
14 }
15 self
16 }
17 pub fn into_result(self) -> Result<FederatedGraph, Diagnostics> {
22 if let Some(federated_graph) = self.federated_graph {
23 Ok(federated_graph)
24 } else {
25 Err(self.diagnostics)
27 }
28 }
29
30 pub fn diagnostics(&self) -> &Diagnostics {
32 &self.diagnostics
33 }
34}