strawberry-graphql/strawberry

`create_type` Throws error of field not having a name

Opened this issue · 2 comments

Describe the Bug

ValueError: Field doesn't have a name. Fields passed to create_type must define a name by passing the name argument to strawberry.field.

It seems like that there is an issue when using create_type and passing fields.

Looking at the code here it uses python_name

if field.python_name is None:

which seems to be hardcoded to None here

python_name=None,

System Information

  • Operating system: Mac
  • Strawberry version (if applicable): 0.221.1

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

@jakubikan can you show us an example of the code that triggers this issue? 😊

It basically happens when you don't pass a resolver to field

 my_name = strawberry.field(name="myName")
 query = create_type(f"Query", [my_name])