Struct apollo_router::graphql::Request
source · #[non_exhaustive]pub struct Request {
pub query: Option<String>,
pub operation_name: Option<String>,
pub variables: Map<ByteString, Value>,
pub extensions: Map<ByteString, Value>,
}Expand description
A GraphQL Request used to represent both supergraph and subgraph requests.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.query: Option<String>The GraphQL operation (e.g., query, mutation) string.
For historical purposes, the term “query” is commonly used to refer to
any GraphQL operation which might be, e.g., a mutation.
operation_name: Option<String>The (optional) GraphQL operation name.
When specified, this name must match the name of an operation in the
GraphQL document. When excluded, there must exist only a single
operation in the GraphQL document. Typically, this value is provided as
the operationName on an HTTP-sourced GraphQL request.
variables: Map<ByteString, Value>The (optional) GraphQL variables in the form of a JSON object.
When specified, these variables can be referred to in the query by
using $variableName syntax, where {"variableName": "value"} has been
specified as this variables value.
extensions: Map<ByteString, Value>The (optional) GraphQL extensions of a GraphQL request.
The implementations of extensions are server specific and not specified by
the GraphQL specification.
For example, Apollo projects support Automated Persisted Queries
which are specified in the extensions of a request by populating the
persistedQuery key within the extensions object:
{
"query": "...",
"variables": { /* ... */ },
"extensions": {
"persistedQuery": {
"version": 1,
"sha256Hash": "sha256HashOfQuery"
. }
}
}
Implementations§
source§impl Request
impl Request
sourcepub fn deserialize_from_bytes(data: &Bytes) -> Result<Self, Error>
pub fn deserialize_from_bytes(data: &Bytes) -> Result<Self, Error>
Deserialize as JSON from &Bytes, avoiding string copies where possible
sourcepub fn from_urlencoded_query(
url_encoded_query: String
) -> Result<Request, Error>
pub fn from_urlencoded_query( url_encoded_query: String ) -> Result<Request, Error>
Convert encoded URL query string parameters (also known as “search
params”) into a GraphQL Request.
An error will be produced in the event that the query string parameters
cannot be turned into a valid GraphQL Request.
source§impl Request
impl Request
sourcepub fn builder(
) -> __RequestBuilder<(__Optional<Option<String>>, __Optional<Option<String>>, __Optional<Map<ByteString, Value>>, __Optional<Map<ByteString, Value>>)>
pub fn builder( ) -> __RequestBuilder<(__Optional<Option<String>>, __Optional<Option<String>>, __Optional<Map<ByteString, Value>>, __Optional<Map<ByteString, Value>>)>
This is the constructor (or builder) to use when constructing a GraphQL
Request.
The optionality of parameters on this constructor match the runtime
requirements which are necessary to create a valid GraphQL Request.
(This contrasts against the fake_new constructor which may be more
tolerant to missing properties which are only necessary for testing
purposes. If you are writing tests, you may want to use Self::fake_new().)
source§impl Request
impl Request
sourcepub fn fake_builder(
) -> __RequestBuilder<(__Optional<Option<String>>, __Optional<Option<String>>, __Optional<Map<ByteString, Value>>, __Optional<Map<ByteString, Value>>)>
pub fn fake_builder( ) -> __RequestBuilder<(__Optional<Option<String>>, __Optional<Option<String>>, __Optional<Map<ByteString, Value>>, __Optional<Map<ByteString, Value>>)>
This is the constructor (or builder) to use when constructing a fake
GraphQL Request. Use Self::new() to construct a real request.
This is offered for testing purposes and it relaxes the requirements
of some parameters to be specified that would be otherwise required
for a real request. It’s usually enough for most testing purposes,
especially when a fully constructed Request is difficult to construct.
While today, its paramters have the same optionality as its new
counterpart, that may change in future versions.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Request
impl<'de> Deserialize<'de> for Request
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for Request
impl PartialEq for Request
impl Eq for Request
Auto Trait Implementations§
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnwindSafe for Request
Blanket Implementations§
source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Requestsource§impl<T> Serializable for Twhere
T: Serialize,
impl<T> Serializable for Twhere
T: Serialize,
source§impl<T> Variant for T
impl<T> Variant for T
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Variant trait object to &mut dyn Any.source§fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
Variant trait object to Box<dyn Any>.