1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
//! # MockForge GraphQL
//!
//! GraphQL mocking library for MockForge with schema-based query execution.
//!
//! This crate provides GraphQL mocking capabilities including:
//!
//! - **Schema-Based Mocking**: Define GraphQL schemas and automatically generate resolvers
//! - **Query & Mutation Support**: Handle queries, mutations, and subscriptions
//! - **Type System**: Full GraphQL type system support (scalars, objects, interfaces, unions)
//! - **Introspection**: Built-in introspection queries for tooling
//! - **Playground Integration**: GraphQL Playground UI for interactive testing
//!
//! ## Overview
//!
//! MockForge GraphQL allows you to define GraphQL schemas and automatically mock
//! resolvers with realistic data. Perfect for frontend development and integration testing.
//!
//! ## Quick Start
//!
//! ### Basic GraphQL Server
//!
//! ```rust,no_run
//! use mockforge_graphql::start;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
//! // Start GraphQL server on port 4000
//! start(4000).await?;
//! Ok(())
//! }
//! ```
//!
//! ### With Custom Schema
//!
//! ```rust,no_run
//! use mockforge_graphql::{create_graphql_router, GraphQLSchema};
//! use mockforge_core::LatencyProfile;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
//! let schema = GraphQLSchema::generate_basic_schema();
//! assert!(schema.schema().sdl().contains("type Query"));
//! let latency = Some(LatencyProfile::with_normal_distribution(80, 20.0));
//! let _router = create_graphql_router(latency).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## GraphQL Schema Example
//!
//! Define your GraphQL schema:
//!
//! ```graphql
//! type Query {
//! user(id: ID!): User
//! users(limit: Int = 10): [User!]!
//! }
//!
//! type Mutation {
//! createUser(input: CreateUserInput!): User!
//! updateUser(id: ID!, input: UpdateUserInput!): User!
//! }
//!
//! type User {
//! id: ID!
//! name: String!
//! email: String!
//! posts: [Post!]!
//! }
//!
//! type Post {
//! id: ID!
//! title: String!
//! content: String!
//! author: User!
//! }
//!
//! input CreateUserInput {
//! name: String!
//! email: String!
//! }
//! ```
//!
//! MockForge automatically generates resolvers with realistic data:
//!
//! ```bash
//! # Query
//! curl -X POST http://localhost:4000/graphql \
//! -H "Content-Type: application/json" \
//! -d '{"query": "{ user(id: \"123\") { id name email } }"}'
//!
//! # Mutation
//! curl -X POST http://localhost:4000/graphql \
//! -H "Content-Type: application/json" \
//! -d '{"query": "mutation { createUser(input: {name: \"Alice\", email: \"alice@example.com\"}) { id } }"}'
//! ```
//!
//! ## GraphQL Playground
//!
//! Access the interactive GraphQL Playground at:
//! ```text
//! http://localhost:4000/playground
//! ```
//!
//! The Playground provides:
//! - Schema explorer
//! - Query editor with auto-complete
//! - Response viewer
//! - Request history
//!
//! ## Features
//!
//! ### Automatic Resolver Generation
//! - Generates realistic data based on field names and types
//! - Maintains referential integrity between related types
//! - Supports nested queries and relationships
//!
//! ### Latency Simulation
//! - Simulate network delays for realistic testing
//! - Per-resolver latency configuration
//! - Random or fixed latency profiles
//!
//! ### Error Injection
//! - Simulate GraphQL errors and partial responses
//! - Configure error rates per resolver
//! - Test error handling in client applications
//!
//! ## Key Modules
//!
//! - [`executor`]: GraphQL query execution engine
//! - [`schema`]: Schema parsing and validation
//! - [`registry`]: Type and resolver registry
//! - [`graphql_tracing`]: Distributed tracing integration
//!
//! ## Examples
//!
//! See the [examples directory](https://github.com/SaaSy-Solutions/mockforge/tree/main/examples)
//! for complete working examples.
//!
//! ## Related Crates
//!
//! - [`mockforge-core`](https://docs.rs/mockforge-core): Core mocking functionality
//! - [`mockforge-data`](https://docs.rs/mockforge-data): Synthetic data generation
//!
//! ## Documentation
//!
//! - [MockForge Book](https://docs.mockforge.dev/)
//! - [GraphQL Mocking Guide](https://docs.mockforge.dev/user-guide/graphql-mocking.html)
//! - [API Reference](https://docs.rs/mockforge-graphql)
use LatencyProfile;
/// Unified protocol server lifecycle implementation
pub use ;
pub use ;
pub use ;
pub use GraphQLSchemaRegistry;
pub use GraphQLSchema;
pub use SchemaWatcher;
pub use ;
// Re-export tracing utilities
pub use ;
/// Start GraphQL server with default configuration
pub async
/// Start GraphQL server with latency configuration
pub async
/// Create a GraphQL router with latency support
pub async