Skip to content

Commit 4d9967e

Browse files
committed
graphql: Remove spawn_blocking from execute_root_selection_set
1 parent bd58d19 commit 4d9967e

File tree

1 file changed

+16
-43
lines changed

1 file changed

+16
-43
lines changed

graphql/src/execution/execution.rs

Lines changed: 16 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -374,50 +374,23 @@ pub(crate) async fn execute_root_selection_set<R: Resolver>(
374374
let _permit = execute_ctx.resolver.query_permit().await;
375375
let query_start = Instant::now();
376376

377-
let logger = execute_ctx.logger.clone();
378-
let query_text = execute_ctx.query.query_text.cheap_clone();
379-
let variables_text = execute_ctx.query.variables_text.cheap_clone();
380-
match graph::spawn_blocking_allow_panic(move || {
381-
let mut query_res = QueryResult::from(
382-
graph::block_on(execute_root_selection_set_uncached(
383-
&execute_ctx,
384-
&execute_selection_set,
385-
&execute_root_type,
386-
))
387-
.map(|(obj, mut trace)| {
388-
trace.query_done(query_start.elapsed(), &_permit);
389-
(obj, trace)
390-
}),
391-
);
377+
let mut query_res = QueryResult::from(
378+
execute_root_selection_set_uncached(
379+
&execute_ctx,
380+
&execute_selection_set,
381+
&execute_root_type,
382+
)
383+
.await
384+
.map(|(obj, mut trace)| {
385+
trace.query_done(query_start.elapsed(), &_permit);
386+
(obj, trace)
387+
}),
388+
);
392389

393-
// Unwrap: In practice should never fail, but if it does we will catch the panic.
394-
execute_ctx.resolver.post_process(&mut query_res).unwrap();
395-
query_res.deployment = Some(execute_ctx.query.schema.id().clone());
396-
Arc::new(query_res)
397-
})
398-
.await
399-
{
400-
Ok(result) => result,
401-
Err(e) => {
402-
let e = e.into_panic();
403-
let e = match e
404-
.downcast_ref::<String>()
405-
.map(String::as_str)
406-
.or(e.downcast_ref::<&'static str>().copied())
407-
{
408-
Some(e) => e.to_string(),
409-
None => "panic is not a string".to_string(),
410-
};
411-
error!(
412-
logger,
413-
"panic when processing graphql query";
414-
"panic" => e.to_string(),
415-
"query" => query_text,
416-
"variables" => variables_text,
417-
);
418-
Arc::new(QueryResult::from(QueryExecutionError::Panic(e)))
419-
}
420-
}
390+
// Unwrap: In practice should never fail, but if it does we will catch the panic.
391+
execute_ctx.resolver.post_process(&mut query_res).unwrap();
392+
query_res.deployment = Some(execute_ctx.query.schema.id().clone());
393+
Arc::new(query_res)
421394
};
422395

423396
let (result, herd_hit) = if let Some(key) = key {

0 commit comments

Comments
 (0)