Skip to content

Commit a4a5b30

Browse files
committed
refactor: Allow unsetting count arg
1 parent 321d33e commit a4a5b30

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/graphql_complexity/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
@dataclasses.dataclass(frozen=True)
55
class Config:
6-
count_arg_name: str = "first"
6+
count_arg_name: str | None = "first" # ToDo: Improve Unset
77
count_missing_arg_value: int = 1

tests/test_lists.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ def test_complexity_reads_count_from_query_args_with_different_name():
3838
assert complexity == 12
3939

4040

41+
def test_complexity_with_arg_name_unset_ignores_lists():
42+
query = """query {
43+
droid {
44+
friends(first: 10) {
45+
name
46+
}
47+
}
48+
}"""
49+
50+
complexity = get_complexity(query, build_schema(schema), SimpleEstimator(), Config(count_arg_name=None))
51+
52+
assert complexity == 3
53+
54+
4155
def test_complexity_config_allows_penalizing_missing_count_argument():
4256
query = """query {
4357
droid {

0 commit comments

Comments
 (0)