Crate apollo_router

source ·
Expand description

Components of a federated GraphQL Server.

Most of these modules are of varying interest to different audiences.

If your interests are confined to developing plugins, then the following modules are likely to be of most interest to you:

  • self - this module (apollo_router) contains high level building blocks for a federated GraphQL router

  • graphql - graphql specific functionality for requests, responses, errors

  • layers - examples of tower layers used to implement plugins

  • plugin - various APIs for implementing a plugin

  • services - the various services handling a GraphQL requests, and APIs for plugins to intercept them

Re-exports§

  • pub use crate::axum_factory::unsupported_set_axum_router_callback;
  • pub use crate::test_harness::MockedSubgraphs;
  • pub use crate::test_harness::TestHarness;

Modules§

  • Types related to GraphQL requests, responses, etc.
  • Reusable layers Layers that are specific to one plugin should not be placed in this module.
  • Plugin system for the router.
  • Implementation of the various steps in the router’s processing pipeline.
  • Test harness and mocks for the Apollo Router.
  • Trace Ids for the router.

Macros§

  • This is a really simple macro to assert a snapshot of the logs. To use it call .with_subscriber(assert_snapshot_subscriber!()) in your test just before calling await. This will assert a snapshot of the logs in pretty yaml format. You can also use subscriber::with_default(assert_snapshot_subscriber!(), || { … }) to assert the logs in non async code.
  • Register a plugin with a group and a name Grouping prevent name clashes for plugins, so choose something unique, like your domain name. Plugins will appear in the configuration as a layer property called: {group}.{name}
  • Register a private plugin with a group and a name Grouping prevent name clashes for plugins, so choose something unique, like your domain name. Plugins will appear in the configuration as a layer property called: {group}.{name}
  • Get or create a u64 monotonic counter metric and add a value to it

Structs§

  • The configuration for the router.
  • A map of arbitrary JSON values, for use by plugins.
  • A path and a handler to be exposed as a web_endpoint for plugins
  • Entry point into creating a router executable with more customization than main.
  • A type map of protocol extensions.
  • You can use Extensions to pass data between plugins that is not serializable. Such data is not accessible from Rhai or co-processoers.
  • In memory pub/sub implementation
  • The entry point for running the Router’s HTTP server.
  • Configuration for polling Apollo Uplink. This struct does not change on router reloads - they are all sourced from CLI options.

Enums§

  • Error types for FederatedServer.
  • The user supplied config. Either a static instance or a stream for hot reloading.
  • License controls availability of certain features of the Router. This API experimental and is subject to change outside of semver.
  • Listening address.
  • The user supplied schema. Either a static string or a stream for hot reloading.
  • Specifies when the Router’s HTTP server should gracefully shutdown

Functions§

  • This is the main router entrypoint.