client = <FlaskClient <Flask 'swh.graphql.tests.conftest'>>
def test_query_cost_snapshots(client):
query_str = """
{
snapshot(swhid: "%s") {
branches(first: 50) {
nodes {
target {
...on Revision {
swhid
}
...on Directory {
swhid
entries(first: 3) {
nodes {
type
}
}
}
}
}
}
}
}
"""
# Total cost here is 157
# 1 (snapshot) + 2 *50 (branches) + 50 * 1 (revision or Directory) + 3 * 2 = 157
# parent multiplier is not applied when schema introspection is used
# ie: directory entry connection cost is 3 * 2 and not 50 * 3 * 2
errors = utils.get_error_response(client, query_str % get_snapshots()[0].swhid())
> assert (
"The query exceeds the maximum cost of 100. Actual cost is 157"
in errors[0]["message"]
)
E assert 'The query exceeds the maximum cost of 100. Actual cost is 157' in "Cannot query field 'type' on type 'DirectoryEntry'."
.tox/py3/lib/python3.7/site-packages/swh/graphql/tests/functional/test_query_cost.py:108: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Sep 27 2022, 3:40 PM