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 Twhere
T: Serialize + ?Sized,
impl<T> Serialize for Twhere T: Serialize + ?Sized,
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
ยงimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
ยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
ยงimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
ยง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 Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
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> Variant for Twhere
T: Any + Clone + SendSync,
impl<T> Variant for Twhere T: Any + Clone + SendSync,
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>.