Struct apollo_router::services::supergraph::Response
source ยท #[non_exhaustive]pub struct Response {
pub response: Response<ResponseStream>,
pub context: Context,
}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.response: Response<ResponseStream>ยงcontext: ContextImplementationsยง
sourceยงimpl Response
impl Response
sourcepub fn builder() -> NewResponseBuilder
pub fn builder() -> NewResponseBuilder
This is the constructor (or builder) to use when constructing a real Response..
Required parameters are required in non-testing code to create a Response..
sourceยงimpl Response
impl Response
sourcepub fn fake_builder() -> FakeNewResponseBuilder
pub fn fake_builder() -> FakeNewResponseBuilder
This is the constructor (or builder) to use when constructing a โfakeโ Response.
This does not enforce the provision of the data that is required for a fully functional Response. Itโs usually enough for testing, when a fully constructed Response is difficult to construct and not required for the purposes of the test.
In addition, fake responses are expected to be valid, and will panic if given invalid values.
sourceยงimpl Response
impl Response
sourcepub fn fake_stream_builder() -> FakeStreamNewResponseBuilder
pub fn fake_stream_builder() -> FakeStreamNewResponseBuilder
This is the constructor (or builder) to use when constructing a โfakeโ Response stream.
This does not enforce the provision of the data that is required for a fully functional Response. Itโs usually enough for testing, when a fully constructed Response is difficult to construct and not required for the purposes of the test.
In addition, fake responses are expected to be valid, and will panic if given invalid values.
sourceยงimpl Response
impl Response
sourcepub fn error_builder() -> ErrorNewResponseBuilder
pub fn error_builder() -> ErrorNewResponseBuilder
This is the constructor (or builder) to use when constructing a Response that represents a global error. It has no path and no response data. This is useful for things such as authentication errors.
sourceยงimpl Response
impl Response
pub async fn next_response(&mut self) -> Option<Response>
pub fn map<F>(self, f: F) -> Response
sourcepub fn map_stream<F>(self, f: F) -> Self
pub fn map_stream<F>(self, f: F) -> Self
Returns a new supergraph response where each graphql::Response is mapped through f.
In supergraph and execution services, the service response contains
not just one GraphQL response but a stream of them,
in order to support features such as @defer.
This method uses futures::stream::StreamExt::map to map over each item in the stream.
ยงExample
use apollo_router::services::supergraph;
use apollo_router::layers::ServiceExt as _;
use tower::ServiceExt as _;
struct ExamplePlugin;
#[async_trait::async_trait]
impl apollo_router::plugin::Plugin for ExamplePlugin {
// โฆ
fn supergraph_service(&self, inner: supergraph::BoxService) -> supergraph::BoxService {
inner
.map_response(|supergraph_response| {
supergraph_response.map_stream(|graphql_response| {
// Something interesting here
graphql_response
})
})
.boxed()
}
}Auto Trait Implementationsยง
impl !RefUnwindSafe for Response
impl Send for Response
impl !Sync for Response
impl Unpin for Response
impl !UnwindSafe for Response
Blanket Implementationsยง
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<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::Request