Skip to content

Setting strawberry.unset as a default does not set the input arguments as optional ones. #3804

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

Open
akademy opened this issue Mar 12, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@akademy
Copy link

akademy commented Mar 12, 2025

Describe the Bug

With an input to a mutation like the following, neither of the inputs are optional, you must specify both:

@strawberry.input
class UserUpdateInput: 
    name: str = strawberry.UNSET 
    description: str = strawberry.UNSET

We get an error like ""Field 'UpdateInput.name' of required type 'String!' was not provided."

If I set them to any other default value then they do become optional, as expected.

System Information

  • Strawberry version (if applicable): strawberry-graphql[fastapi]==0.262.1

Additional Context

I am also trying to avoid setting the name to have a None value as this conflicts with my database setup (a non-nullable value)

Perhaps I am missunderstanding the way this should be working....

@akademy akademy added the bug Something isn't working label Mar 12, 2025
@patrick91
Copy link
Member

@akademy that's the expected behaviour, we have a PR to make this better #3791 :D

In your case I guess you have to use None for the time being I think 😊

@akademy
Copy link
Author

akademy commented Mar 12, 2025

OK. Good to know!

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

2 participants