Can default values form cycles?
还没有人认领这个 Issue。
评估
调研方向
从 graphql/utilities/build_ast_schema.py 以及经过 graphql/utilities/value_from_ast.py、graphql/type/definition.py 和 graphql/type/schema.py 的 traceback 路径开始。使用报告中所述的 Python 和 graphql-core 版本重现递归的 InputA/InputB schema,然后将其行为与 GraphQL 规范进行比较。完成标准是:根据规范对 issue 进行分类,并使递归默认值获得经过明确设计和测试的结果,而不是无界的 RecursionError。
由索引模型根据 Issue 内容生成。
描述
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?
- 主要语言
- Python
- 星标
- 531
- 派生
- 147
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
graphql-python/graphql-core 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 50/100
graphql-python/graphql-core#272 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 55/100
graphql-python/graphql-core#269 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 35/100
graphql-python/graphql-core#267 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 45/100
graphql-python/graphql-core#257 ·
-
难度 5/5 一周以上 新手友好度 25/100
graphql-python/graphql-core#247 · 8 条评论 ·
查看 graphql-python/graphql-core 的全部 Issue
相似的 Issue
-
essnmx good first issue
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 2/5 1-3 小时 新手友好度 65/100
syfoud/Simulated_Scepter#174 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
Giskard-AI/giskard-oss#2840 · 1 条评论 ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success 未关闭area: repo bug perceived difficulty: 2
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
yeti-platform/yeti#1380 ·