grafbase_sdk/
extension.rs

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