Skip to content

Commit 0d8f976

Browse files
committed
graphql: Move special handling of scalar relations in prefetch into fetch
1 parent 3d287e9 commit 0d8f976

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

graphql/src/store/prefetch.rs

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ fn execute_field(
771771
field: &q::Field,
772772
field_definition: &s::Field,
773773
) -> Result<Vec<Node>, Vec<QueryExecutionError>> {
774-
let mut argument_values = match object_type {
774+
let argument_values = match object_type {
775775
ObjectOrInterface::Object(object_type) => {
776776
crate::execution::coerce_argument_values(ctx, object_type, field)
777777
}
@@ -797,31 +797,13 @@ fn execute_field(
797797
}
798798
}?;
799799

800-
let is_list = sast::is_list_or_non_null_list_field(field_definition);
801-
if !argument_values.contains_key(&*ARG_FIRST) {
802-
let first = if is_list {
803-
// This makes `build_range` use the default, 100
804-
q::Value::Null
805-
} else {
806-
// For non-list fields, get up to 2 entries so we can spot
807-
// ambiguous references that should only have one entry
808-
q::Value::Int(2.into())
809-
};
810-
argument_values.insert(&*ARG_FIRST, first);
811-
}
812-
813-
if !argument_values.contains_key(&*ARG_SKIP) {
814-
// Use the default in build_range
815-
argument_values.insert(&*ARG_SKIP, q::Value::Null);
816-
}
817-
818800
fetch(
819801
ctx.logger.clone(),
820802
resolver.store.as_ref(),
821803
&parents,
822804
&join,
823-
&argument_values,
824-
is_list,
805+
argument_values,
806+
sast::is_list_or_non_null_list_field(field_definition),
825807
ctx.query.schema.types_for_interface(),
826808
resolver.block,
827809
ctx.max_first,
@@ -836,16 +818,33 @@ fn fetch<S: Store>(
836818
store: &S,
837819
parents: &Vec<Node>,
838820
join: &Join<'_>,
839-
arguments: &HashMap<&q::Name, q::Value>,
821+
mut arguments: HashMap<&q::Name, q::Value>,
840822
is_list: bool,
841823
types_for_interface: &BTreeMap<s::Name, Vec<s::ObjectType>>,
842824
block: BlockNumber,
843825
max_first: u32,
844826
) -> Result<Vec<Node>, QueryExecutionError> {
827+
if !arguments.contains_key(&*ARG_FIRST) {
828+
let first = if is_list {
829+
// This makes `build_range` use the default, 100
830+
q::Value::Null
831+
} else {
832+
// For non-list fields, get up to 2 entries so we can spot
833+
// ambiguous references that should only have one entry
834+
q::Value::Int(2.into())
835+
};
836+
arguments.insert(&*ARG_FIRST, first);
837+
}
838+
839+
if !arguments.contains_key(&*ARG_SKIP) {
840+
// Use the default in build_range
841+
arguments.insert(&*ARG_SKIP, q::Value::Null);
842+
}
843+
845844
let mut query = build_query(
846845
join.child_type,
847846
block,
848-
arguments,
847+
&arguments,
849848
types_for_interface,
850849
max_first,
851850
)?;

0 commit comments

Comments
 (0)