Trait async_graphql::extensions::Extension
source · pub trait Extension: Sync + Send + 'static {
fn request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
next: NextRequest<'life3>
) -> Pin<Box<dyn Future<Output = Response> + Send + 'async_trait>>
where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
{ ... }
fn subscribe<'s>(
&self,
ctx: &ExtensionContext<'_>,
stream: BoxStream<'s, Response>,
next: NextSubscribe<'_>
) -> BoxStream<'s, Response> { ... }
fn prepare_request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
request: Request,
next: NextPrepareRequest<'life3>
) -> Pin<Box<dyn Future<Output = ServerResult<Request>> + Send + 'async_trait>>
where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
{ ... }
fn parse_query<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
query: &'life3 str,
variables: &'life4 Variables,
next: NextParseQuery<'life5>
) -> Pin<Box<dyn Future<Output = ServerResult<ExecutableDocument>> + Send + 'async_trait>>
where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
'life5: 'async_trait,
{ ... }
fn validation<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
next: NextValidation<'life3>
) -> Pin<Box<dyn Future<Output = Result<ValidationResult, Vec<ServerError>>> + Send + 'async_trait>>
where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
{ ... }
fn execute<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
operation_name: Option<&'life3 str>,
next: NextExecute<'life4>
) -> Pin<Box<dyn Future<Output = Response> + Send + 'async_trait>>
where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
{ ... }
fn resolve<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
info: ResolveInfo<'life3>,
next: NextResolve<'life4>
) -> Pin<Box<dyn Future<Output = ServerResult<Option<Value>>> + Send + 'async_trait>>
where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
{ ... }
}
Expand description
Represents a GraphQL extension
Provided Methods§
sourcefn request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
next: NextRequest<'life3>
) -> Pin<Box<dyn Future<Output = Response> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
next: NextRequest<'life3>
) -> Pin<Box<dyn Future<Output = Response> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Called at start query/mutation request.
Examples found in repository?
src/extensions/mod.rs (lines 156-162)
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
pub async fn run(self, ctx: &ExtensionContext<'_>) -> Response {
if let Some((first, next)) = self.chain.split_first() {
first
.request(
ctx,
NextRequest {
chain: next,
request_fut: self.request_fut,
},
)
.await
} else {
self.request_fut.await
}
}
sourcefn subscribe<'s>(
&self,
ctx: &ExtensionContext<'_>,
stream: BoxStream<'s, Response>,
next: NextSubscribe<'_>
) -> BoxStream<'s, Response>
fn subscribe<'s>(
&self,
ctx: &ExtensionContext<'_>,
stream: BoxStream<'s, Response>,
next: NextSubscribe<'_>
) -> BoxStream<'s, Response>
Called at subscribe request.
sourcefn prepare_request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
request: Request,
next: NextPrepareRequest<'life3>
) -> Pin<Box<dyn Future<Output = ServerResult<Request>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn prepare_request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
request: Request,
next: NextPrepareRequest<'life3>
) -> Pin<Box<dyn Future<Output = ServerResult<Request>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Called at prepare request.
sourcefn parse_query<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
query: &'life3 str,
variables: &'life4 Variables,
next: NextParseQuery<'life5>
) -> Pin<Box<dyn Future<Output = ServerResult<ExecutableDocument>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
'life5: 'async_trait,
fn parse_query<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
query: &'life3 str,
variables: &'life4 Variables,
next: NextParseQuery<'life5>
) -> Pin<Box<dyn Future<Output = ServerResult<ExecutableDocument>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
'life5: 'async_trait,
Called at parse query.
Examples found in repository?
src/extensions/mod.rs (lines 224-232)
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
pub async fn run(
self,
ctx: &ExtensionContext<'_>,
query: &str,
variables: &Variables,
) -> ServerResult<ExecutableDocument> {
if let Some((first, next)) = self.chain.split_first() {
first
.parse_query(
ctx,
query,
variables,
NextParseQuery {
chain: next,
parse_query_fut: self.parse_query_fut,
},
)
.await
} else {
self.parse_query_fut.await
}
}
sourcefn validation<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
next: NextValidation<'life3>
) -> Pin<Box<dyn Future<Output = Result<ValidationResult, Vec<ServerError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn validation<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
next: NextValidation<'life3>
) -> Pin<Box<dyn Future<Output = Result<ValidationResult, Vec<ServerError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Called at validation query.
Examples found in repository?
src/extensions/mod.rs (lines 254-260)
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
pub async fn run(
self,
ctx: &ExtensionContext<'_>,
) -> Result<ValidationResult, Vec<ServerError>> {
if let Some((first, next)) = self.chain.split_first() {
first
.validation(
ctx,
NextValidation {
chain: next,
validation_fut: self.validation_fut,
},
)
.await
} else {
self.validation_fut.await
}
}
sourcefn execute<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
operation_name: Option<&'life3 str>,
next: NextExecute<'life4>
) -> Pin<Box<dyn Future<Output = Response> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
operation_name: Option<&'life3 str>,
next: NextExecute<'life4>
) -> Pin<Box<dyn Future<Output = Response> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Called at execute query.
Examples found in repository?
src/extensions/mod.rs (lines 279-286)
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
pub async fn run(self, ctx: &ExtensionContext<'_>, operation_name: Option<&str>) -> Response {
if let Some((first, next)) = self.chain.split_first() {
first
.execute(
ctx,
operation_name,
NextExecute {
chain: next,
execute_fut: self.execute_fut,
},
)
.await
} else {
self.execute_fut.await
}
}
sourcefn resolve<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
info: ResolveInfo<'life3>,
next: NextResolve<'life4>
) -> Pin<Box<dyn Future<Output = ServerResult<Option<Value>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn resolve<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
ctx: &'life1 ExtensionContext<'life2>,
info: ResolveInfo<'life3>,
next: NextResolve<'life4>
) -> Pin<Box<dyn Future<Output = ServerResult<Option<Value>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Called at resolve field.
Examples found in repository?
src/extensions/mod.rs (lines 309-316)
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
pub async fn run(
self,
ctx: &ExtensionContext<'_>,
info: ResolveInfo<'_>,
) -> ServerResult<Option<Value>> {
if let Some((first, next)) = self.chain.split_first() {
first
.resolve(
ctx,
info,
NextResolve {
chain: next,
resolve_fut: self.resolve_fut,
},
)
.await
} else {
self.resolve_fut.await
}
}