Skip to content

3.5 Beta: overlapping_fields_can_be_merged: directives are None #447

Closed
@theCapypara

Description

@theCapypara

Describe the bug
I upgraded to the 3.5 Beta and now queries fail in overlapping_fields_can_be_merged.py in get_stream_directive. The directives are None, if I go up the stack they are always None. They are read from node1 and node2 in lines 563 - 564, and they are already None at the nodes.

...

  File "/home/marco/dev/skytemple/skytemple/files/skytemple_files/common/spritecollab/client.py", line 671, in execute_query
    return cast(Query, await self._session.execute(dsl_gql(*fragments, query)))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marco/.virtualenvs/skytemple/lib/python3.11/site-packages/gql/client.py", line 1629, in execute
    result = await self._execute(
             ^^^^^^^^^^^^^^^^^^^^
  File "/home/marco/.virtualenvs/skytemple/lib/python3.11/site-packages/gql/client.py", line 1817, in _execute
    return await self._execute_with_retries(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marco/.virtualenvs/skytemple/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marco/.virtualenvs/skytemple/lib/python3.11/site-packages/gql/client.py", line 1790, in _execute_once
    answer = await super()._execute(
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marco/.virtualenvs/skytemple/lib/python3.11/site-packages/gql/client.py", line 1520, in _execute
    self.client.validate(document)
  File "/home/marco/.virtualenvs/skytemple/lib/python3.11/site-packages/gql/client.py", line 172, in validate
    validation_errors = validate(self.schema, document)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marco/.virtualenvs/skytemple/lib/python3.11/site-packages/graphql/validation/validate.py", line 73, in validate
    visit(document_ast, TypeInfoVisitor(type_info, ParallelVisitor(visitors)))
  File "/home/marco/.virtualenvs/skytemple/lib/python3.11/site-packages/graphql/language/visitor.py", line 257, in visit
    result = visit_fn(node, key, parent, path, ancestors)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marco/.virtualenvs/skytemple/lib/python3.11/site-packages/graphql/utilities/type_info.py", line 280, in enter
    result = fn(node, *args)
             ^^^^^^^^^^^^^^^
  File "/home/marco/.virtualenvs/skytemple/lib/python3.11/site-packages/graphql/language/visitor.py", line 339, in enter
    result = fn(node, *args)
             ^^^^^^^^^^^^^^^
  File "/home/marco/.virtualenvs/skytemple/lib/python3.11/site-packages/graphql/validation/rules/overlapping_fields_can_be_merged.py", line 76, in enter_selection_set
    conflicts = find_conflicts_within_selection_set(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marco/.virtualenvs/skytemple/lib/python3.11/site-packages/graphql/validation/rules/overlapping_fields_can_be_merged.py", line 210, in find_conflicts_within_selection_set
    collect_conflicts_between_fragments(
  File "/home/marco/.virtualenvs/skytemple/lib/python3.11/site-packages/graphql/validation/rules/overlapping_fields_can_be_merged.py", line 324, in collect_conflicts_between_fragments
    collect_conflicts_between(
  File "/home/marco/.virtualenvs/skytemple/lib/python3.11/site-packages/graphql/validation/rules/overlapping_fields_can_be_merged.py", line 502, in collect_conflicts_between
    conflict = find_conflict(
               ^^^^^^^^^^^^^^
  File "/home/marco/.virtualenvs/skytemple/lib/python3.11/site-packages/graphql/validation/rules/overlapping_fields_can_be_merged.py", line 565, in find_conflict
    if not same_streams(directives1, directives2):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marco/.virtualenvs/skytemple/lib/python3.11/site-packages/graphql/validation/rules/overlapping_fields_can_be_merged.py", line 622, in same_streams
    stream1 = get_stream_directive(directives1)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/marco/.virtualenvs/skytemple/lib/python3.11/site-packages/graphql/validation/rules/overlapping_fields_can_be_merged.py", line 613, in get_stream_directive
    for directive in directives:
TypeError: 'NoneType' object is not iterable

field1 and field2 are:

field1:

parent_type1.__dict__ =  {'name': 'Sprite', 'description': 'A single sprite for a single action.', 'extensions': {}, 'ast_node': None, 'extension_ast_nodes': (), '_fields': <function build_client_schema.<locals>.build_object_def.<locals>.<lambda> at 0x7fd2293791c0>, '_interfaces': <function build_client_schema.<locals>.build_object_def.<locals>.<lambda> at 0x7fd229379120>, 'is_type_of': None, 'interfaces': (), 'fields': {'action': <GraphQLField <GraphQLNonNull <GraphQLScalarType 'String'>>>, 'locked': <GraphQLField <GraphQLNonNull <GraphQLScalarType 'Boolean'>>>, 'animUrl': <GraphQLField <GraphQLNonNull <GraphQLScalarType 'String'>>>, 'offsetsUrl': <GraphQLField <GraphQLNonNull <GraphQLScalarType 'String'>>>, 'shadowsUrl': <GraphQLField <GraphQLNonNull <GraphQLScalarType 'String'>>>}}
node1.to_dict() = {'alias': None, 'arguments': [], 'directives': None, 'kind': 'field', 'name': {'kind': 'name', 'value': 'action'}, 'nullability_assertion': None, 'selection_set': None}
def1.__dict__ = {'args': {}, 'ast_node': None, 'deprecation_reason': None, 'description': 'Action of this sprite.', 'extensions': {}, 'resolve': None, 'subscribe': None, 'type': String!}

field2:

parent_type2.__dict__ =  {'name': 'CopyOf', 'description': 'A sprite, which is a copy of another sprite.', 'extensions': {}, 'ast_node': None, 'extension_ast_nodes': (), '_fields': <function build_client_schema.<locals>.build_object_def.<locals>.<lambda> at 0x7fd229378900>, '_interfaces': <function build_client_schema.<locals>.build_object_def.<locals>.<lambda> at 0x7fd229378860>, 'is_type_of': None, 'interfaces': (), 'fields': {'action': <GraphQLField <GraphQLNonNull <GraphQLScalarType 'String'>>>, 'locked': <GraphQLField <GraphQLNonNull <GraphQLScalarType 'Boolean'>>>, 'copyOf': <GraphQLField <GraphQLNonNull <GraphQLScalarType 'String'>>>}}
node2.to_dict() = {'alias': None, 'arguments': [], 'directives': None, 'kind': 'field', 'name': {'kind': 'name', 'value': 'action'}, 'nullability_assertion': None, 'selection_set': None}
def2.__dict__ = {'args': {}, 'ast_node': None, 'deprecation_reason': None, 'description': 'Action of this sprite.', 'extensions': {}, 'resolve': None, 'subscribe': None, 'type': String!}

To Reproduce
Using gql and aiohttp 3.9., query the following GraphQL server with the following document (JSON encoded, sorry I don't know any way to get the raw query and variables out of the document:

Server: https://spriteserver.pmdcollab.org
Query document: https://gist.github.com/theCapypara/2c38f3c1da9607010627a4c03979d74f

Expected behavior
The query returns the result.

System info (please complete the following information):

  • OS: Arch Linux
  • Python version: Python 3.11
  • gql version: 3.5.0b7
  • graphql-core version: 3.3.0a3

This blocks my project from upgrading to Python 3.12. I have been anticipating aiohttp finally upgrading to be 3.12 compatible and am now stuck due to this.

PS: I know the dependencies are currently locked so that aiohttp 3.8 is used for Python 3.11, however I was unable to get 3.12 compiled locally. If this error is because the combination 3.11 + aiohttp 3.9 is not supported, I'm sorry!

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugAn issue or pull request relating to a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions