Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relay.node on subtype needs initialization #3129

Open
devkral opened this issue Oct 2, 2023 · 1 comment
Open

relay.node on subtype needs initialization #3129

devkral opened this issue Oct 2, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@devkral
Copy link
Contributor

devkral commented Oct 2, 2023

Consider the code

@strawberry.type
class Sub:
  node: relay.Node =  relay.node()
  nodes: list[relay.Node] =  relay.node()

@strawberry.type
class Query:
  @strawberry.field
  @staticmethod
  def sub():
    return Sub

schema = Schema(query=Query)

This code should work but doesn't, it requires an initialization for node

Note there is a workaround (initialization with None or empty list, or (I think whatever))

...
  @strawberry.field
  @staticmethod
  def sub():
    return Sub(node=None, nodes=None)

Describe the Bug

System Information

  • Operating system:
  • Strawberry version (if applicable): since strawberry-django-plus times after a rewrite, there is a bugreport in the old repo

Additional Context

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@devkral devkral added the bug Something isn't working label Oct 2, 2023
@devkral
Copy link
Contributor Author

devkral commented Jan 10, 2024

there is a better workaround: just provide a default of None

devkral added a commit to devkral/strawberry that referenced this issue Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant