Struct async_graphql::extensions::ExtensionContext

source ·
pub struct ExtensionContext<'a> { /* private fields */ }
Expand description

Context for extension

Implementations§

source§

impl<'a> ExtensionContext<'a>

source

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.

source

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.

source

pub fn data_unchecked<D: Any + Send + Sync>(&self) -> &'a D

Gets the global data defined in the Context or Schema.

§Panics

It will panic if the specified data type does not exist.

source

pub fn data_opt<D: Any + Send + Sync>(&self) -> Option<&'a D>

Gets the global data defined in the Context or Schema or None if the specified type data does not exist.

Trait Implementations§

source§

impl<'a> DataContext<'a> for ExtensionContext<'a>

source§

fn data<D: Any + Send + Sync>(&self) -> Result<&'a D>

Gets the global data defined in the Context or Schema. Read more
source§

fn data_unchecked<D: Any + Send + Sync>(&self) -> &'a D

Gets the global data defined in the Context or Schema. Read more
source§

fn data_opt<D: Any + Send + Sync>(&self) -> Option<&'a D>

Gets the global data defined in the Context or Schema or None if the specified type data does not exist.

Auto Trait Implementations§

§

impl<'a> Freeze for ExtensionContext<'a>

§

impl<'a> !RefUnwindSafe for ExtensionContext<'a>

§

impl<'a> Send for ExtensionContext<'a>

§

impl<'a> Sync for ExtensionContext<'a>

§

impl<'a> Unpin for ExtensionContext<'a>

§

impl<'a> !UnwindSafe for ExtensionContext<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.