Struct async_graphql::Schema

source ·
pub struct Schema<Query, Mutation, Subscription>(/* private fields */);
Expand description

GraphQL schema.

Cloning a schema is cheap, so it can be easily shared.

Implementations§

source§

impl<Query, Mutation, Subscription> Schema<Query, Mutation, Subscription>
where Query: ObjectType + 'static, Mutation: ObjectType + 'static, Subscription: SubscriptionType + 'static,

source

pub fn build( query: Query, mutation: Mutation, subscription: Subscription, ) -> SchemaBuilder<Query, Mutation, Subscription>

Create a schema builder

The root object for the query and Mutation needs to be specified. If there is no mutation, you can use EmptyMutation. If there is no subscription, you can use EmptySubscription.

source

pub fn build_with_ignore_name_conflicts<I, T>( query: Query, mutation: Mutation, subscription: Subscription, ignore_name_conflicts: I, ) -> SchemaBuilder<Query, Mutation, Subscription>
where I: IntoIterator<Item = T>, T: Into<String>,

Create a schema builder and specifies a list to ignore type conflict detection.

NOTE: It is not recommended to use it unless you know what it does.

source

pub fn new( query: Query, mutation: Mutation, subscription: Subscription, ) -> Schema<Query, Mutation, Subscription>

Create a schema

source

pub fn sdl(&self) -> String

Returns SDL(Schema Definition Language) of this schema.

source

pub fn sdl_with_options(&self, options: SDLExportOptions) -> String

Returns SDL(Schema Definition Language) of this schema with options.

source

pub fn names(&self) -> Vec<String>

Get all names in this schema

Maybe you want to serialize a custom binary protocol. In order to minimize message size, a dictionary is usually used to compress type names, field names, directive names, and parameter names. This function gets all the names, so you can create this dictionary.

source

pub async fn execute(&self, request: impl Into<Request>) -> Response

Execute a GraphQL query.

source

pub async fn execute_batch(&self, batch_request: BatchRequest) -> BatchResponse

Execute a GraphQL batch query.

source

pub fn execute_stream_with_session_data( &self, request: impl Into<Request>, session_data: Arc<Data>, ) -> impl Stream<Item = Response> + Send + Unpin

Execute a GraphQL subscription with session data.

source

pub fn execute_stream( &self, request: impl Into<Request>, ) -> impl Stream<Item = Response> + Send + Unpin

Execute a GraphQL subscription.

Trait Implementations§

source§

impl<Query, Mutation, Subscription> Clone for Schema<Query, Mutation, Subscription>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Query, Mutation, Subscription> Default for Schema<Query, Mutation, Subscription>
where Query: Default + ObjectType + 'static, Mutation: Default + ObjectType + 'static, Subscription: Default + SubscriptionType + 'static,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<Query, Mutation, Subscription> Executor for Schema<Query, Mutation, Subscription>
where Query: ObjectType + 'static, Mutation: ObjectType + 'static, Subscription: SubscriptionType + 'static,

source§

async fn execute(&self, request: Request) -> Response

Execute a GraphQL query.
source§

fn execute_stream( &self, request: Request, session_data: Option<Arc<Data>>, ) -> BoxStream<'static, Response>

Execute a GraphQL subscription with session data.
source§

fn execute_batch( &self, batch_request: BatchRequest, ) -> impl Future<Output = BatchResponse> + Send

Execute a GraphQL batch query.

Auto Trait Implementations§

§

impl<Query, Mutation, Subscription> Freeze for Schema<Query, Mutation, Subscription>

§

impl<Query, Mutation, Subscription> !RefUnwindSafe for Schema<Query, Mutation, Subscription>

§

impl<Query, Mutation, Subscription> Send for Schema<Query, Mutation, Subscription>
where Mutation: Sync + Send, Subscription: Sync + Send, Query: Sync + Send,

§

impl<Query, Mutation, Subscription> Sync for Schema<Query, Mutation, Subscription>
where Mutation: Sync + Send, Subscription: Sync + Send, Query: Sync + Send,

§

impl<Query, Mutation, Subscription> Unpin for Schema<Query, Mutation, Subscription>

§

impl<Query, Mutation, Subscription> !UnwindSafe for Schema<Query, Mutation, Subscription>

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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.