pub struct ExtensionContext<'a> {
pub schema_env: &'a SchemaEnv,
pub session_data: &'a Data,
pub query_data: Option<&'a Data>,
}Expand description
Context for extension
Fields§
§schema_env: &'a SchemaEnvSchema-scope context data, [Registry], and custom directives.
session_data: &'a DataExtension-scoped context data shared across all extensions.
Can be accessed only from hooks that implement the Extension trait.
It is created with each new Request and is empty by default.
For subscriptions, the session ends when the subscription is closed.
query_data: Option<&'a Data>Request-scoped context data shared across all resolvers.
This is a reference to Request::data field.
If the request has not initialized yet, the value is seen as None
inside the Extension::request, Extension::subscribe, and
Extension::prepare_request hooks.
Implementations§
Source§impl<'a> ExtensionContext<'a>
impl<'a> ExtensionContext<'a>
Sourcepub fn stringify_execute_doc(
&self,
doc: &ExecutableDocument,
variables: &Variables,
) -> String
pub fn stringify_execute_doc( &self, doc: &ExecutableDocument, variables: &Variables, ) -> String
Convert the specified ExecutableDocument into a query string.
Usually used for log extension, it can hide secret arguments.
Sourcepub fn sdl_with_options(&self, options: SDLExportOptions) -> String
pub fn sdl_with_options(&self, options: SDLExportOptions) -> String
Returns SDL(Schema Definition Language) of this schema with options.
Sourcepub fn data<D: Any + Send + Sync>(&self) -> Result<&'a D>
pub fn data<D: Any + Send + Sync>(&self) -> Result<&'a D>
Gets the global data defined in the Context or Schema.
If both Schema and Query have the same data type, the data in the
Query is obtained.
§Errors
Returns a Error if the specified type data does not exist.