use petgraph::graph::NodeIndex;
use crate::query_planner::{
graph::error::GraphError, state::supergraph_state::OperationKind,
utils::cancellation::CancellationError,
};
#[derive(Debug, Clone, thiserror::Error)]
pub enum WalkOperationError {
#[error("Root type of {0} not found")]
MissingRootType(OperationKind),
#[error("Graph error: {0}")]
GraphFailure(Box<GraphError>),
#[error("Tail node missing info")]
TailMissingInfo(NodeIndex),
#[error("Type Definition of '{0}' not found in Supergraph")]
TypeNotFound(String),
#[error("Field '{0}' not found in type '{1}'")]
FieldNotFound(String, String),
#[error("No paths found for selection item: {0}")]
NoPathsFound(String),
#[error(transparent)]
CancellationError(#[from] CancellationError),
#[error("The shareable field '{field_name}' on interface '{type_name}' is not resolvable by all of its object types in all subgraphs, which violates the '@shareable' contract.")]
InconsistentShareableField {
field_name: String,
type_name: String,
},
}
impl From<GraphError> for WalkOperationError {
fn from(error: GraphError) -> Self {
WalkOperationError::GraphFailure(Box::new(error))
}
}