Skip to content

Commit

Permalink
Add more fold-related edge cases to the test suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
obi1kenobi committed Apr 12, 2023
1 parent 2611481 commit 25a7692
Show file tree
Hide file tree
Showing 20 changed files with 1,294 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
Ok(TestParsedGraphQLQuery(
schema_name: "numbers",
query: Query(
root_connection: FieldConnection(
position: Pos(
line: 3,
column: 5,
),
name: "One",
),
root_field: FieldNode(
position: Pos(
line: 3,
column: 5,
),
name: "One",
connections: [
(FieldConnection(
position: Pos(
line: 4,
column: 9,
),
name: "value",
), FieldNode(
position: Pos(
line: 4,
column: 9,
),
name: "value",
output: [
OutputDirective(),
],
tag: [
TagDirective(),
],
)),
(FieldConnection(
position: Pos(
line: 6,
column: 9,
),
name: "successor",
), FieldNode(
position: Pos(
line: 6,
column: 9,
),
name: "successor",
connections: [
(FieldConnection(
position: Pos(
line: 7,
column: 13,
),
name: "predecessor",
fold: Some(FoldGroup(
fold: FoldDirective(),
transform: Some(TransformGroup(
transform: TransformDirective(
kind: Count,
),
filter: [
FilterDirective(
operation: GreaterThanOrEqual((), TagRef("value")),
),
],
)),
)),
), FieldNode(
position: Pos(
line: 7,
column: 13,
),
name: "predecessor",
connections: [
(FieldConnection(
position: Pos(
line: 8,
column: 17,
),
name: "value",
), FieldNode(
position: Pos(
line: 8,
column: 17,
),
name: "value",
filter: [
FilterDirective(
operation: Equals((), TagRef("value")),
),
],
output: [
OutputDirective(),
],
)),
],
transform_group: Some(TransformGroup(
transform: TransformDirective(
kind: Count,
),
filter: [
FilterDirective(
operation: GreaterThanOrEqual((), TagRef("value")),
),
],
)),
)),
],
)),
],
),
),
))
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
TestGraphQLQuery (
schema_name: "numbers",
// When resolving `One` or its `successor` edge, the `value` property inside `predecessor`
// now has a known value: if it isn't the number 1, then the result set will be discarded
// by the fold-count-filter sequence.
query: r#"
{
One {
value @tag @output
successor {
predecessor @fold @transform(op: "count") @filter(op: ">=", value: ["%value"]) {
value @filter(op: "=", value: ["%value"]) @output
}
}
}
}"#,
arguments: {},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Err(MultipleOutputsWithSameName(DuplicatedNamesConflict(
duplicates: {
"value": [
("Number", "value"),
("Number", "value"),
],
},
)))
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
Ok(TestParsedGraphQLQuery(
schema_name: "numbers",
query: Query(
root_connection: FieldConnection(
position: Pos(
line: 3,
column: 5,
),
name: "One",
),
root_field: FieldNode(
position: Pos(
line: 3,
column: 5,
),
name: "One",
connections: [
(FieldConnection(
position: Pos(
line: 4,
column: 9,
),
name: "successor",
), FieldNode(
position: Pos(
line: 4,
column: 9,
),
name: "successor",
connections: [
(FieldConnection(
position: Pos(
line: 5,
column: 13,
),
name: "predecessor",
fold: Some(FoldGroup(
fold: FoldDirective(),
transform: Some(TransformGroup(
transform: TransformDirective(
kind: Count,
),
filter: [
FilterDirective(
operation: GreaterThanOrEqual((), VariableRef("one")),
),
],
)),
)),
), FieldNode(
position: Pos(
line: 5,
column: 13,
),
name: "predecessor",
connections: [
(FieldConnection(
position: Pos(
line: 6,
column: 17,
),
name: "value",
), FieldNode(
position: Pos(
line: 6,
column: 17,
),
name: "value",
filter: [
FilterDirective(
operation: Equals((), VariableRef("one")),
),
],
)),
],
transform_group: Some(TransformGroup(
transform: TransformDirective(
kind: Count,
),
filter: [
FilterDirective(
operation: GreaterThanOrEqual((), VariableRef("one")),
),
],
)),
)),
],
)),
],
),
),
arguments: {
"one": Int64(1),
},
))
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
TestGraphQLQuery (
schema_name: "numbers",
// When resolving `One` or its `successor` edge, the `value` property inside `predecessor`
// now has a known value: if it isn't the number 1, then the result set will be discarded
// by the fold-count-filter sequence.
query: r#"
{
One {
successor {
predecessor @fold @transform(op: "count") @filter(op: ">=", value: ["$one"]) {
value @filter(op: "=", value: ["$one"]) @output
}
}
}
}"#,
arguments: {
"one": Int64(1),
},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Ok(TestIRQuery(
schema_name: "numbers",
ir_query: IRQuery(
root_name: "One",
root_component: IRQueryComponent(
root: Vid(1),
vertices: {
Vid(1): IRVertex(
vid: Vid(1),
type_name: "Number",
),
Vid(2): IRVertex(
vid: Vid(2),
type_name: "Number",
),
},
edges: {
Eid(1): IREdge(
eid: Eid(1),
from_vid: Vid(1),
to_vid: Vid(2),
edge_name: "successor",
),
},
folds: {
Eid(2): IRFold(
eid: Eid(2),
from_vid: Vid(2),
to_vid: Vid(3),
edge_name: "predecessor",
component: IRQueryComponent(
root: Vid(3),
vertices: {
Vid(3): IRVertex(
vid: Vid(3),
type_name: "Number",
filters: [
Equals(LocalField(
field_name: "value",
field_type: "Int",
), Variable(VariableRef(
variable_name: "one",
variable_type: "Int",
))),
],
),
},
),
post_filters: [
GreaterThanOrEqual(Count, Variable(VariableRef(
variable_name: "one",
variable_type: "Int!",
))),
],
),
},
),
variables: {
"one": "Int!",
},
),
arguments: {
"one": Int64(1),
},
))
Loading

0 comments on commit 25a7692

Please sign in to comment.