Skip to main content

Request

Struct Request 

Source
#[non_exhaustive]
pub struct Request { pub query: String, pub operation_name: Option<String>, pub variables: Variables, pub uploads: Vec<UploadValue>, pub data: Data, pub extensions: Extensions, pub introspection_mode: IntrospectionMode, /* private fields */ }
Expand description

GraphQL request.

This can be deserialized from a structure of the query string, the operation name and the variables. The names are all in camelCase (e.g. operationName).

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§query: String

The query source of the request.

§operation_name: Option<String>

The operation name of the request.

§variables: Variables

The variables of the request.

§uploads: Vec<UploadValue>

Uploads sent with the request.

§data: Data

The data of the request that can be accessed through Context::data.

This data is only valid for this request

§extensions: Extensions

The extensions config of the request.

§introspection_mode: IntrospectionMode

Sets the introspection mode for this request (defaults to IntrospectionMode::Enabled).

Implementations§

Source§

impl Request

Source

pub fn new(query: impl Into<String>) -> Request

Create a request object with query source.

Source

pub fn operation_name<T>(self, name: T) -> Request
where T: Into<String>,

Specify the operation name of the request.

Source

pub fn variables(self, variables: Variables) -> Request

Specify the variables.

Source

pub fn data<D>(self, data: D) -> Request
where D: Any + Send + Sync,

Insert some data for this request.

Source

pub fn disable_introspection(self) -> Request

Disable introspection queries for this request.

Source

pub fn only_introspection(self) -> Request

Only allow introspection queries for this request.

Source

pub fn parsed_query(&mut self) -> Result<&ExecutableDocument, ServerError>

Performs parsing of query ahead of execution.

This effectively allows to inspect query information, before passing request to schema for execution as long as query is valid.

Source

pub fn set_parsed_query(&mut self, doc: ExecutableDocument)

Sets the parsed query into the request.

This is useful special with dynamic schema when the query has been parsed ahead of time. It can reduce performance overhead of parsing the query again.

Source

pub fn set_upload(&mut self, var_path: &str, upload: UploadValue)

Set a variable to an upload value.

var_path is a dot-separated path to the item that begins with variables, for example variables.files.2.content is equivalent to the Rust code request.variables["files"][2]["content"]. If no variable exists at the path this function won’t do anything.

Trait Implementations§

Source§

impl Debug for Request

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Request

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Request, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> From<T> for Request
where T: Into<String>,

Source§

fn from(query: T) -> Request

Converts to this type from the input type.
Source§

impl Serialize for Request

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> DynamicRequestExt for T
where T: Into<Request>,

Source§

fn root_value(self, value: FieldValue<'static>) -> DynamicRequest

Specify the root value for the request
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,