Skip to content

Commit c021f40

Browse files
committed
improve an error message
1 parent efb7ca4 commit c021f40

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/builder.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,15 @@ where
14721472

14731473
for selection_field in selection_fields {
14741474
match field_map.get(selection_field.name.as_ref()) {
1475-
None => return Err("unknown field in connection".to_string()),
1475+
None => {
1476+
let error = if selection_field.name.as_ref() == "aggregate" {
1477+
"enable the aggregate directive to use aggregates"
1478+
} else {
1479+
"unknown field in connection"
1480+
}
1481+
.to_string();
1482+
return Err(error);
1483+
}
14761484
Some(f) => builder_fields.push(match &f.type_.unmodified_type() {
14771485
__Type::Edge(_) => ConnectionSelection::Edge(to_edge_builder(
14781486
f,

test/expected/aggregate_directive.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ select graphql.resolve($$
2121
}
2222
}
2323
$$);
24-
resolve
25-
------------------------------------------------------------------------
26-
{"data": null, "errors": [{"message": "unknown field in connection"}]}
24+
resolve
25+
---------------------------------------------------------------------------------------------
26+
{"data": null, "errors": [{"message": "enable the aggregate directive to use aggregates"}]}
2727
(1 row)
2828

2929
-- Enable aggregates

0 commit comments

Comments
 (0)