//! GraphQL parsing and query processing.
//!
//! This module provides runtime GraphQL query handling:
//! - Query parsing via `graphql-parser` crate
//! - Fragment resolution and expansion
//! - Directive evaluation (@skip, @include)
//! - Fragment cycle detection
//!
//! # Architecture
//!
//! ```text
//! Incoming GraphQL Query
//!         │
//!         ▼
//!   ┌─────────────┐
//!   │   Parser    │  ← graphql-parser crate
//!   └──────┬──────┘
//!          │ ParsedQuery
//!          ▼
//!   ┌─────────────┐
//!   │  Fragment   │  ← Cycle detection
//!   │  Validator  │
//!   └──────┬──────┘
//!          │
//!          ▼
//!   ┌─────────────┐
//!   │  Fragment   │  ← Spread expansion
//!   │  Resolver   │
//!   └──────┬──────┘
//!          │ Resolved selections
//!          ▼
//!   ┌─────────────┐
//!   │  Directive  │  ← @skip/@include
//!   │  Evaluator  │
//!   └──────┬──────┘
//!          │ Final field list
//!          ▼
//!     SQL Generation
//! ```
//!
//! # Example
//!
//! ```no_run
//! // Requires: fraiseql_core graphql module (internal types).
//! use fraiseql_core::graphql::{parse_query, FragmentResolver, DirectiveEvaluator};
//! # fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let query = r#"
//!     fragment UserFields on User { id name }
//!     query { users { ...UserFields } }
//! "#;
//!
//! let parsed = parse_query(query)?;
//! let resolver = FragmentResolver::new(&parsed.fragments);
//! let resolved = resolver.resolve_spreads(&parsed.selections)?;
//! # Ok(())
//! # }
//! ```

// ============================================================================
// Module declarations
// ============================================================================

/// GraphQL AST types for query representation.
pub mod types;

/// GraphQL query parsing wrapper.
pub mod parser;

/// Fragment resolution and expansion.
pub mod fragment_resolver;

/// Directive evaluation (@skip, @include).
pub mod directive_evaluator;

/// Fragment cycle detection.
pub mod fragments;

/// Query complexity analysis and `DoS` prevention.
pub mod complexity;

/// Field-level RBAC directive (@require_permission).
pub mod require_permission_directive;

// ============================================================================
// Re-exports for convenient access
// ============================================================================

pub use complexity::{
    ComplexityConfig, ComplexityValidationError, DEFAULT_MAX_ALIASES, MAX_VARIABLES_COUNT,
    QueryMetrics, RequestValidator, estimate_query_cost, parse_graphql_document,
};
pub use directive_evaluator::{
    CustomDirectiveEvaluator, DirectiveError, DirectiveEvaluator, DirectiveHandler,
    DirectiveResult, EvaluationContext, OperationType,
};
pub use fragment_resolver::{FragmentError, FragmentResolver};
pub use fragments::FragmentGraph;
pub use parser::parse_query;
pub use require_permission_directive::RequirePermissionDirective;
pub use types::{
    Directive, FieldSelection, FragmentDefinition, GraphQLArgument, GraphQLType, ParsedQuery,
    VariableDefinition,
};

// ============================================================================
// Test modules
// ============================================================================

#[cfg(test)]
mod tests;
