Skip to content

Need to define a resolver if query can return Connection or null #723

Open
@rcybulski1122012

Description

@rcybulski1122012

Recently strawberry added support for optional Connections. If graphql_type for strwaberry_django.connection is nullable, it is required to provide a resolver.

Describe the Bug

By default, if I define a query with pagination the resolver is not needed:

@strawberry.type
class Query:
    some_types = strawberry_django.connection(
        graphql_type=ListConnection[SomeType],
    )

But when graphql_type is nullable, the query returns the following error:

Django connection without a resolver needs to define a connection for one and only one django type. To use it in a union, define your own resolver that handles each of those

System Information

  • Operating system: MacOS 14.7.3 (23H417)
  • Strawberry version (if applicable): 0.262.5
  • Strawberry-django version: 0.57.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions