grafbase_sdk/
extension.rs

1pub mod authentication;
2pub mod authorization;
3pub mod resolver;
4
5pub use authentication::Authenticator;
6pub use resolver::Resolver;
7
8use crate::types::Configuration;
9
10/// A trait representing an extension that can be initialized from schema directives.
11///
12/// This trait is intended to define a common interface for extensions in Grafbase Gateway,
13/// particularly focusing on their initialization. Extensions are constructed using
14/// a vector of `Directive` instances provided by the type definitions in the schema.
15pub trait Extension: 'static {
16    /// Creates a new instance of the extension from the given schema directives.
17    ///
18    /// The directives must be defined in the extension configuration, and written
19    /// to the federated schema. The directives are deserialized from their GraphQL
20    /// definitions to the corresponding `Directive` instances.
21    fn new(
22        schema_directives: Vec<crate::types::SchemaDirective>,
23        config: Configuration,
24    ) -> Result<Self, Box<dyn std::error::Error>>
25    where
26        Self: Sized;
27}