grafbase_sdk/
extension.rs

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