Skip to content
This repository was archived by the owner on Feb 6, 2025. It is now read-only.

Commit c0b6ddb

Browse files
Add pagination test with inline fragment (#908)
* Add pagination test with inline fragment * Lint * Trigger CI rebuild
1 parent 365477a commit c0b6ddb

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

graphql_compiler/tests/snapshot_tests/test_query_pagination.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,3 +1770,65 @@ def test_pagination_missing_edge_class_count(self) -> None:
17701770
first_page_and_remainder, advisories = paginate_query(schema_info, query, 1)
17711771
self.assertTrue(first_page_and_remainder.remainder == tuple())
17721772
self.assertEqual(advisories, (MissingClassCount("Animal_LivesIn"),))
1773+
1774+
@pytest.mark.xfail(strict=True, reason="inline fragment not supported", raises=Exception)
1775+
@pytest.mark.usefixtures("snapshot_orientdb_client")
1776+
def test_pagination_with_inline_fragment(self) -> None:
1777+
schema_graph = generate_schema_graph(self.orientdb_client) # type: ignore # from fixture
1778+
graphql_schema, type_equivalence_hints = get_graphql_schema_from_schema_graph(schema_graph)
1779+
pagination_keys = {vertex_name: "uuid" for vertex_name in schema_graph.vertex_class_names}
1780+
pagination_keys["Species"] = "limbs" # Force pagination on int field
1781+
uuid4_field_info = {
1782+
vertex_name: {"uuid": UUIDOrdering.LeftToRight}
1783+
for vertex_name in schema_graph.vertex_class_names
1784+
}
1785+
class_counts = {"Species": 1000}
1786+
statistics = LocalStatistics(
1787+
class_counts, field_quantiles={("Species", "limbs"): list(range(100))},
1788+
)
1789+
schema_info = QueryPlanningSchemaInfo(
1790+
schema=graphql_schema,
1791+
type_equivalence_hints=type_equivalence_hints,
1792+
schema_graph=schema_graph,
1793+
statistics=statistics,
1794+
pagination_keys=pagination_keys,
1795+
uuid4_field_info=uuid4_field_info,
1796+
)
1797+
1798+
query = QueryStringWithParameters(
1799+
"""{
1800+
Species {
1801+
out_Entity_Related {
1802+
... on Species {
1803+
name @output(out_name: "species_name")
1804+
}
1805+
}
1806+
}
1807+
}""",
1808+
{},
1809+
)
1810+
analysis = analyze_query_string(schema_info, query)
1811+
1812+
vertex_partition_plan = VertexPartitionPlan(("Species", "out_Entity_Related"), "limbs", 2)
1813+
1814+
generated_parameters = generate_parameters_for_vertex_partition(
1815+
schema_info, analysis.ast_with_parameters, vertex_partition_plan
1816+
)
1817+
1818+
sentinel = object()
1819+
first_param = next(generated_parameters, sentinel)
1820+
self.assertEqual(50, first_param)
1821+
1822+
page_query, _ = generate_parameterized_queries(analysis, vertex_partition_plan, first_param)
1823+
1824+
expected_page_query_string = """{
1825+
Species {
1826+
out_Entity_Related {
1827+
... on Species {
1828+
limbs @filter(op_name: "<", value: ["$__paged_param_0"])
1829+
name @output(out_name: "species_name")
1830+
}
1831+
}
1832+
}
1833+
}"""
1834+
compare_graphql(self, expected_page_query_string, print_ast(page_query.query_ast))

0 commit comments

Comments
 (0)