Skip to main content

apollo_router/
lib.rs

1//! Components of a federated GraphQL Server.
2//!
3//! Most of these modules are of varying interest to different audiences.
4//!
5//! If your interests are confined to developing plugins, then the following modules
6//! are likely to be of most interest to you:
7//!
8//! * [`self`] - this module (apollo_router) contains high level building blocks for a federated GraphQL router
9//!
10//! * [`graphql`] - graphql specific functionality for requests, responses, errors
11//!
12//! * [`layers`] - examples of tower layers used to implement plugins
13//!
14//! * [`plugin`] - various APIs for implementing a plugin
15//!
16//! * [`services`] - the various services handling a GraphQL requests,
17//!   and APIs for plugins to intercept them
18
19#![cfg_attr(feature = "failfast", allow(unreachable_code))]
20#![warn(unreachable_pub)]
21#![warn(missing_docs)]
22
23macro_rules! failfast_debug {
24    ($($tokens:tt)+) => {{
25        tracing::debug!($($tokens)+);
26        #[cfg(feature = "failfast")]
27        panic!(
28            "failfast triggered. \
29            Please remove the feature failfast if you don't want to see these panics"
30        );
31    }};
32}
33
34macro_rules! failfast_error {
35    ($($tokens:tt)+) => {{
36        tracing::error!($($tokens)+);
37        #[cfg(feature = "failfast")]
38        panic!(
39            "failfast triggered. \
40            Please remove the feature failfast if you don't want to see these panics"
41        );
42    }};
43}
44
45#[macro_use]
46mod json_ext;
47#[macro_use]
48pub mod plugin;
49
50#[macro_use]
51pub mod metrics;
52
53mod ageing_priority_queue;
54mod apollo_studio_interop;
55pub(crate) mod axum_factory;
56mod batching;
57mod cache;
58mod compute_job;
59mod configuration;
60mod context;
61mod error;
62mod executable;
63mod files;
64pub mod graphql;
65mod http_ext;
66mod http_server_factory;
67mod introspection;
68pub mod layers;
69pub(crate) mod logging;
70mod orbiter;
71mod plugins;
72pub(crate) mod protocols;
73mod query_planner;
74mod router;
75mod router_factory;
76pub mod services;
77pub(crate) mod spec;
78mod state_machine;
79pub mod test_harness;
80pub mod tracer;
81mod uplink;
82
83pub(crate) mod allocator;
84#[doc(hidden)]
85#[deprecated(
86    since = "2.16.0",
87    note = "Will be removed in 3.0. Use opentelemetry_http::HeaderExtractor / opentelemetry_http::HeaderInjector directly."
88)]
89pub mod otel_compat;
90mod registry;
91
92pub use crate::configuration::Configuration;
93pub use crate::configuration::ListenAddr;
94pub use crate::context::Context;
95pub use crate::context::extensions::Extensions;
96pub use crate::context::extensions::sync::ExtensionsMutex;
97pub use crate::executable::Executable;
98pub use crate::executable::main;
99pub use crate::plugins::subscription::notification::Notify;
100pub use crate::router::ApolloRouterError;
101pub use crate::router::ConfigurationSource;
102pub use crate::router::LicenseSource;
103pub use crate::router::RouterHttpServer;
104pub use crate::router::SchemaSource;
105pub use crate::router::ShutdownSource;
106pub use crate::router_factory::Endpoint;
107pub use crate::test_harness::MockedSubgraphs;
108pub use crate::test_harness::TestHarness;
109#[cfg(any(test, feature = "snapshot"))]
110pub use crate::test_harness::http_snapshot::SnapshotServer;
111#[cfg(any(test, feature = "snapshot"))]
112pub use crate::test_harness::http_snapshot::standalone::main as snapshot_server;
113pub use crate::test_harness::make_fake_batch;
114pub use crate::uplink::UplinkConfig;
115pub use crate::uplink::license_enforcement::AllowedFeature;
116
117/// Not part of the public API
118#[doc(hidden)]
119pub mod _private {
120    // Reexports for macros
121    pub use linkme;
122    pub use once_cell;
123    pub use serde_json;
124
125    pub use crate::plugin::PLUGINS;
126    pub use crate::plugin::PluginFactory;
127    // For tests
128    pub use crate::plugins::mock_subgraphs::testing_subgraph_call as mock_subgraphs_subgraph_call;
129    pub use crate::router_factory::create_test_service_factory_from_yaml;
130    pub use crate::services::APOLLO_GRAPH_REF;
131    pub use crate::services::APOLLO_KEY;
132
133    pub fn compute_job_queued_count() -> &'static std::sync::atomic::AtomicUsize {
134        &crate::compute_job::queue().queued_count
135    }
136    pub mod telemetry {
137        pub use crate::plugins::telemetry::config::AttributeValue;
138        pub use crate::plugins::telemetry::resource::ConfigResource;
139    }
140}