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
//! Async-`GraphQL` integration for Tako: extractors, responses, and subscriptions.
//!
//! - GraphQLRequest / GraphQLBatchRequest extractors
//! - GraphQLResponse / GraphQLBatchResponse responders
//! - GraphQLSubscription responder for WebSocket subscriptions
//! - APQ (Apollo Persisted Queries) and execution-cost limits via submodules
//!
//! Enable via the `async-graphql` cargo feature.
//!
//! # DataLoader integration
//!
//! `async_graphql::dataloader::DataLoader` is the canonical way to batch
//! `Object` field resolvers in N+1 patterns. Tako does not wrap it — instead,
//! attach the loader to per-request `Data` and pull it from the resolver:
//!
//! ```rust,ignore
//! use std::sync::Arc;
//! use async_graphql::{Context, dataloader::*};
//!
//! struct UserLoader(/* db handle */);
//!
//! impl Loader<u64> for UserLoader {
//! type Value = User;
//! type Error = Arc<dyn std::error::Error + Send + Sync>;
//! async fn load(&self, keys: &[u64]) -> Result<HashMap<u64, User>, Self::Error> {
//! // SELECT * FROM users WHERE id IN ($keys)
//! # unimplemented!()
//! }
//! }
//!
//! // Per-request: attach the loader to Data.
//! let loader = DataLoader::new(UserLoader(db_handle), tokio::spawn);
//! let request = async_graphql::Request::new(query).data(loader);
//! schema.execute(request).await
//! ```
//!
//! Field resolver:
//!
//! ```rust,ignore
//! use async_graphql::Object;
//!
//! struct Query;
//!
//! #[Object]
//! impl Query {
//! async fn user(&self, ctx: &Context<'_>, id: u64) -> Option<User> {
//! ctx.data_unchecked::<DataLoader<UserLoader>>()
//! .load_one(id)
//! .await
//! .ok()
//! .flatten()
//! }
//! }
//! ```
/// Apollo Persisted Queries (APQ) flow.
/// Execution-cost limits (max depth, max complexity).
pub use GraphQLProtocol;
pub use GraphQLProtocolRejection;
pub use GraphQLBatchRequest;
pub use GraphQLError;
pub use GraphQLOptions;
pub use GraphQLRequest;
pub use MAX_GRAPHQL_BODY_SIZE;
pub use attach_graphql_options;
pub use receive_graphql;
pub use receive_graphql_batch;
pub use set_global_graphql_options;
pub use GraphQLBatchResponse;
pub use GraphQLResponse;
pub use GraphQLSubscription;
pub use GraphQLWebSocket;
pub use crateGraphiQL;
pub use crategraphiql;