Can default values form cycles?
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Bắt đầu với graphql/utilities/build_ast_schema.py và đường dẫn traceback qua graphql/utilities/value_from_ast.py, graphql/type/definition.py và graphql/type/schema.py. Tái hiện schema InputA/InputB đệ quy bằng các phiên bản Python và graphql-core được báo cáo, sau đó so sánh hành vi với đặc tả GraphQL. Công việc được xem là hoàn tất khi issue được phân loại theo đặc tả và các giá trị mặc định đệ quy nhận được một kết quả có chủ đích, đã được kiểm thử, thay vì một RecursionError không có giới hạn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi, I’ve been working with input fields' default values, and I encountered this question - can default values form cycles? I looked into the spec but I haven’t found answer. I tried to create a schema with such values:
from graphql import build_schema
schema_str = """
schema { query: Query }
type Query { _skip: String! }
input InputA {
id: ID!
fieldB: InputB = {id: "1"}
}
input InputB {
id: ID!
fieldA: InputA = {id: "1"}
}
"""
build_schema(schema_str)
I used graphql-core==3.2.3 and python-3.11.1, as a result, I got this exception:
Traceback (most recent call last):
File ".../lib/python3.11/site-packages/graphql/type/definition.py", line 1456, in fields
fields = resolve_thunk(self._fields)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../lib/python3.11/site-packages/graphql/type/definition.py", line 300, in resolve_thunk
return thunk() if callable(thunk) else thunk
^^^^^^^
File ".../lib/python3.11/site-packages/graphql/utilities/extend_schema.py", line 605, in <lambda>
fields=lambda: build_input_field_map(all_nodes),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RecursionError: maximum recursion depth exceeded
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File ".../lib/python3.11/site-packages/graphql/type/definition.py", line 1456, in fields
fields = resolve_thunk(self._fields)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../lib/python3.11/site-packages/graphql/type/definition.py", line 300, in resolve_thunk
return thunk() if callable(thunk) else thunk
^^^^^^^
File ".../lib/python3.11/site-packages/graphql/utilities/extend_schema.py", line 605, in <lambda>
fields=lambda: build_input_field_map(all_nodes),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../lib/python3.11/site-packages/graphql/utilities/extend_schema.py", line 471, in build_input_field_map
default_value=value_from_ast(field.default_value, type_),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../lib/python3.11/site-packages/graphql/utilities/value_from_ast.py", line 107, in value_from_ast
fields = type_.fields
^^^^^^^^^^^^
File "".../lib/python3.11/functools.py", line 1001, in __get__
val = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File ".../lib/python3.11/site-packages/graphql/type/definition.py", line 1459, in fields
raise cls(f"{self.name} fields cannot be resolved. {error}") from error
TypeError: InputB fields cannot be resolved. maximum recursion depth exceeded
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File ".../lib/python3.11/site-packages/graphql/type/definition.py", line 1456, in fields
fields = resolve_thunk(self._fields)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../lib/python3.11/site-packages/graphql/type/definition.py", line 300, in resolve_thunk
return thunk() if callable(thunk) else thunk
^^^^^^^
File ".../lib/python3.11/site-packages/graphql/utilities/extend_schema.py", line 605, in <lambda>
fields=lambda: build_input_field_map(all_nodes),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../lib/python3.11/site-packages/graphql/utilities/extend_schema.py", line 471, in build_input_field_map
default_value=value_from_ast(field.default_value, type_),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../lib/python3.11/site-packages/graphql/utilities/value_from_ast.py", line 107, in value_from_ast
fields = type_.fields
^^^^^^^^^^^^
File "".../lib/python3.11/functools.py", line 1001, in __get__
val = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File ".../lib/python3.11/site-packages/graphql/type/definition.py", line 1459, in fields
raise cls(f"{self.name} fields cannot be resolved. {error}") from error
TypeError: InputA fields cannot be resolved. InputB fields cannot be resolved. maximum recursion depth exceeded
The above exception was the direct cause of the following exception:
...
# 4k lines of the same error, each with extra `InputB fields cannot be resolved.`
...
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "scheam_test.py", line 17, in <module>
build_schema(schema_str)
File ".../lib/python3.11/site-packages/graphql/utilities/build_ast_schema.py", line 95, in build_schema
return build_ast_schema(
^^^^^^^^^^^^^^^^^
File ".../lib/python3.11/site-packages/graphql/utilities/build_ast_schema.py", line 84, in build_ast_schema
return GraphQLSchema(**schema_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../lib/python3.11/site-packages/graphql/type/schema.py", line 218, in __init__
collect_referenced_types(type_)
File ".../lib/python3.11/site-packages/graphql/type/schema.py", line 438, in collect_referenced_types
for field in named_type.fields.values():
^^^^^^^^^^^^^^^^^
File "".../lib/python3.11/functools.py", line 1001, in __get__
val = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File ".../lib/python3.11/site-packages/graphql/type/definition.py", line 1459, in fields
raise cls(f"{self.name} fields cannot be resolved. {error}") from error
TypeError: InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. InputA fields cannot be resolved. InputB fields cannot be resolved. maximum recursion depth exceeded
I wonder if this is not allowed but not mentioned in the specification or is it a bug in graphql-core?
- Ngôn ngữ chính
- Python
- Star
- 531
- Fork
- 147
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của graphql-python/graphql-core
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 50/100
graphql-python/graphql-core#272 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
graphql-python/graphql-core#269 · 1 bình luận ·
-
Publish a major version Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
graphql-python/graphql-core#267 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
graphql-python/graphql-core#257 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
graphql-python/graphql-core#247 · 8 bình luận ·
Tất cả issue của graphql-python/graphql-core
Issue tương tự
-
essnmx good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
-
[Feature] 奇物选择添加优先级 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
syfoud/Simulated_Scepter#174 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Giskard-AI/giskard-oss#2840 · 1 bình luận ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Đang mởarea: repo bug perceived difficulty: 2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
yeti-platform/yeti#1380 ·