-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more test cases for edge cases around
@optional
semantics. (#253)
- Loading branch information
1 parent
4d2e9c8
commit 6565458
Showing
12 changed files
with
1,235 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
...ore/test_data/tests/valid_queries/optional_with_nested_edge_and_filter.graphql-parsed.ron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
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: "predecessor", | ||
optional: Some(OptionalDirective()), | ||
), FieldNode( | ||
position: Pos( | ||
line: 4, | ||
column: 9, | ||
), | ||
name: "predecessor", | ||
connections: [ | ||
(FieldConnection( | ||
position: Pos( | ||
line: 5, | ||
column: 13, | ||
), | ||
name: "successor", | ||
), FieldNode( | ||
position: Pos( | ||
line: 5, | ||
column: 13, | ||
), | ||
name: "successor", | ||
connections: [ | ||
(FieldConnection( | ||
position: Pos( | ||
line: 6, | ||
column: 17, | ||
), | ||
name: "value", | ||
), FieldNode( | ||
position: Pos( | ||
line: 6, | ||
column: 17, | ||
), | ||
name: "value", | ||
filter: [ | ||
FilterDirective( | ||
operation: GreaterThan((), VariableRef("one")), | ||
), | ||
], | ||
output: [ | ||
OutputDirective(), | ||
], | ||
)), | ||
], | ||
)), | ||
], | ||
)), | ||
], | ||
), | ||
), | ||
arguments: { | ||
"one": Int64(1), | ||
}, | ||
)) |
26 changes: 26 additions & 0 deletions
26
...tfall_core/test_data/tests/valid_queries/optional_with_nested_edge_and_filter.graphql.ron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
TestGraphQLQuery ( | ||
schema_name: "numbers", | ||
// This query tests an edge case of the semantics of `@optional` with nested `@filter`. | ||
// | ||
// `@optional` applies *only* to whether the edge exists. After the edge is resolved, | ||
// subsequent edges and filters are resolved normally. If the thus-resolved vertices fail | ||
// to satisfy a subsequent required edge or filter, they are discarded. | ||
// | ||
// We *do not* get to "retroactively" pretend that the edge did not exist at the `@optional` | ||
// and thereby preserve that result set with nulls for the `@optional` contents. | ||
// | ||
// If the below query returns *any* data, that's a bug. | ||
query: r#" | ||
{ | ||
One { | ||
predecessor @optional { | ||
successor { | ||
value @filter(op: ">", value: ["$one"]) @output | ||
} | ||
} | ||
} | ||
}"#, | ||
arguments: { | ||
"one": Int64(1), | ||
}, | ||
) |
60 changes: 60 additions & 0 deletions
60
trustfall_core/test_data/tests/valid_queries/optional_with_nested_edge_and_filter.ir.ron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
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", | ||
), | ||
Vid(3): IRVertex( | ||
vid: Vid(3), | ||
type_name: "Number", | ||
filters: [ | ||
GreaterThan(LocalField( | ||
field_name: "value", | ||
field_type: "Int", | ||
), Variable(VariableRef( | ||
variable_name: "one", | ||
variable_type: "Int!", | ||
))), | ||
], | ||
), | ||
}, | ||
edges: { | ||
Eid(1): IREdge( | ||
eid: Eid(1), | ||
from_vid: Vid(1), | ||
to_vid: Vid(2), | ||
edge_name: "predecessor", | ||
optional: true, | ||
), | ||
Eid(2): IREdge( | ||
eid: Eid(2), | ||
from_vid: Vid(2), | ||
to_vid: Vid(3), | ||
edge_name: "successor", | ||
), | ||
}, | ||
outputs: { | ||
"value": ContextField( | ||
vertex_id: Vid(3), | ||
field_name: "value", | ||
field_type: "Int", | ||
), | ||
}, | ||
), | ||
variables: { | ||
"one": "Int!", | ||
}, | ||
), | ||
arguments: { | ||
"one": Int64(1), | ||
}, | ||
)) |
Oops, something went wrong.