Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Can default values form cycles?

Fechada
#196 3 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
48/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Pouca atividade
Stack de tecnologia
graphql, python
Domínio
api

Direção de pesquisa

Comece por graphql/utilities/build_ast_schema.py e pelo caminho do traceback passando por graphql/utilities/value_from_ast.py, graphql/type/definition.py e graphql/type/schema.py. Reproduza o schema recursivo InputA/InputB com as versões informadas de Python e graphql-core e, em seguida, compare o comportamento com a especificação GraphQL. O trabalho estará concluído quando a issue estiver classificada de acordo com a especificação e os defaults recursivos receberem um resultado deliberado e testado, em vez de um RecursionError sem limite.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

upstream

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?

Linguagem predominante
Python
Estrelas
531
Forks
149
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

  • Sem Dockerfile nem arquivo Docker Compose
  • Tem um modelo de pull request
  • Sem guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de graphql-python/graphql-core

Todas as issues de graphql-python/graphql-core

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.