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)]
85pub mod otel_compat;
86mod registry;
87
88pub use crate::configuration::Configuration;
89pub use crate::configuration::ListenAddr;
90pub use crate::context::Context;
91pub use crate::context::extensions::Extensions;
92pub use crate::context::extensions::sync::ExtensionsMutex;
93pub use crate::executable::Executable;
94pub use crate::executable::main;
95pub use crate::plugins::subscription::notification::Notify;
96pub use crate::router::ApolloRouterError;
97pub use crate::router::ConfigurationSource;
98pub use crate::router::LicenseSource;
99pub use crate::router::RouterHttpServer;
100pub use crate::router::SchemaSource;
101pub use crate::router::ShutdownSource;
102pub use crate::router_factory::Endpoint;
103pub use crate::test_harness::MockedSubgraphs;
104pub use crate::test_harness::TestHarness;
105#[cfg(any(test, feature = "snapshot"))]
106pub use crate::test_harness::http_snapshot::SnapshotServer;
107#[cfg(any(test, feature = "snapshot"))]
108pub use crate::test_harness::http_snapshot::standalone::main as snapshot_server;
109pub use crate::test_harness::make_fake_batch;
110pub use crate::uplink::UplinkConfig;
111pub use crate::uplink::license_enforcement::AllowedFeature;
112
113/// Not part of the public API
114#[doc(hidden)]
115pub mod _private {
116    // Reexports for macros
117    pub use linkme;
118    pub use once_cell;
119    pub use serde_json;
120
121    pub use crate::plugin::PLUGINS;
122    pub use crate::plugin::PluginFactory;
123    // For tests
124    pub use crate::plugins::mock_subgraphs::testing_subgraph_call as mock_subgraphs_subgraph_call;
125    pub use crate::router_factory::create_test_service_factory_from_yaml;
126    pub use crate::services::APOLLO_GRAPH_REF;
127    pub use crate::services::APOLLO_KEY;
128
129    pub fn compute_job_queued_count() -> &'static std::sync::atomic::AtomicUsize {
130        &crate::compute_job::queue().queued_count
131    }
132    pub mod telemetry {
133        pub use crate::plugins::telemetry::config::AttributeValue;
134        pub use crate::plugins::telemetry::resource::ConfigResource;
135    }
136}