Refactor code to remove async move closure which may result in double boxing.
This commit is contained in:
parent
2682ee1418
commit
213cb8de1a
1 changed files with 19 additions and 21 deletions
|
@ -258,31 +258,29 @@ where
|
||||||
let is_non_null = meta_field.field_type.is_non_null();
|
let is_non_null = meta_field.field_type.is_non_null();
|
||||||
|
|
||||||
let response_name = response_name.to_string();
|
let response_name = response_name.to_string();
|
||||||
async_values.push_back(AsyncValueFuture::Field(async move {
|
let res = instance
|
||||||
// TODO: implement custom future type instead of
|
.resolve_field_async(info, f.name.item, &args, &sub_exec)
|
||||||
// two-level boxing.
|
.await;
|
||||||
let res = instance
|
|
||||||
.resolve_field_async(info, f.name.item, &args, &sub_exec)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
let value = match res {
|
let value = match res {
|
||||||
Ok(Value::Null) if is_non_null => None,
|
Ok(Value::Null) if is_non_null => None,
|
||||||
Ok(v) => Some(v),
|
Ok(v) => Some(v),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
sub_exec.push_error_at(e, pos);
|
sub_exec.push_error_at(e, pos);
|
||||||
|
if is_non_null {
|
||||||
if is_non_null {
|
None
|
||||||
None
|
} else {
|
||||||
} else {
|
Some(Value::null())
|
||||||
Some(Value::null())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
AsyncValue::Field(AsyncField {
|
};
|
||||||
|
|
||||||
|
async_values.push_back(AsyncValueFuture::Field(future::ready(AsyncValue::Field(
|
||||||
|
AsyncField {
|
||||||
name: response_name,
|
name: response_name,
|
||||||
value,
|
value,
|
||||||
})
|
},
|
||||||
}));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
Selection::FragmentSpread(Spanning {
|
Selection::FragmentSpread(Spanning {
|
||||||
|
|
Loading…
Add table
Reference in a new issue