Skip to content

Commit e069a6a

Browse files
committed
graphql: Remove PREFETCH_KEY, prefetch is now the only mode
1 parent fe01910 commit e069a6a

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

graphql/src/store/prefetch.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ lazy_static! {
2626
static ref ARG_ID: String = String::from("id");
2727
}
2828

29-
pub const PREFETCH_KEY: &str = ":prefetch";
30-
3129
/// Similar to the TypeCondition from graphql_parser, but with
3230
/// derives that make it possible to use it as the key in a HashMap
3331
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
@@ -146,13 +144,10 @@ fn make_root_node() -> Vec<Node> {
146144
/// Recursively convert a `Node` into the corresponding `q::Value`, which is
147145
/// always a `q::Value::Object`. The entity's associations are mapped to
148146
/// entries `r:{response_key}` as that name is guaranteed to not conflict
149-
/// with any field of the entity. Also add an entry `:prefetch` so that
150-
/// the resolver can later tell whether the `q::Value` was produced by prefetch
151-
/// and should therefore have `r:{response_key}` entries.
147+
/// with any field of the entity.
152148
impl From<Node> for q::Value {
153149
fn from(node: Node) -> Self {
154150
let mut map: BTreeMap<_, _> = node.entity.into();
155-
map.insert(PREFETCH_KEY.to_owned(), q::Value::Boolean(true));
156151
for (key, nodes) in node.children.into_iter() {
157152
map.insert(format!("prefetch:{}", key), node_list_as_value(nodes));
158153
}
@@ -445,9 +440,7 @@ impl<'a> Join<'a> {
445440
/// The returned value contains a `q::Value::Object` that contains a tree of
446441
/// all the entities (converted into objects) in the form in which they need
447442
/// to be returned. Nested object fields appear under the key `r:response_key`
448-
/// in these objects, and are always `q::Value::List` of objects. In addition,
449-
/// each entity has a property `:prefetch` set so that the resolver can
450-
/// tell whether the `r:response_key` associations should be there.
443+
/// in these objects, and are always `q::Value::List` of objects.
451444
///
452445
/// For the above example, the returned object would have one entry under
453446
/// `r:musicians`, which is a list of all the musicians; each musician has an
@@ -462,8 +455,7 @@ pub fn run(
462455
selection_set: &q::SelectionSet,
463456
) -> Result<q::Value, Vec<QueryExecutionError>> {
464457
execute_root_selection_set(resolver, ctx, selection_set).map(|nodes| {
465-
let mut map = BTreeMap::default();
466-
map.insert(PREFETCH_KEY.to_owned(), q::Value::Boolean(true));
458+
let map = BTreeMap::default();
467459
q::Value::Object(nodes.into_iter().fold(map, |mut map, node| {
468460
// For root nodes, we only care about the children
469461
for (key, nodes) in node.children.into_iter() {

0 commit comments

Comments
 (0)