strawberry-graphql / strawberry-django

Strawberry GraphQL Django extension
MIT License
391 stars 115 forks source link

When the optional file field is used, an error will be reported when there are empty files in the query set #545

Open Eraldo opened 3 weeks ago

Eraldo commented 3 weeks ago

Describe the Bug

Current: FileField with blank=True gets resolved as required by auto! Expected: FileField with blank=True gets resolved as optional by auto.

As a temporary workaround I overwrite them explicitly on my type if they are supposed to allow being optional: asset: FileType | None

Error is thrown from here https://github.com/django/django/blob/475cffd1d64c690cdad16ede4d5e81985738ceb4/django/db/models/fields/files.py#L40

System Information

Additional Context

The issue has previously been reported, however the ticket owner closed it for a reason unknown to me. Ref: https://github.com/strawberry-graphql/strawberry-django/issues/58

Upvote & Fund

Fund with Polar

bellini666 commented 3 weeks ago

blank actually doesn't define a field as "nullable", what does is null

But having said that, we do have an issue with FileField/ImageField that we need to fix. More specifically, if the field is not set it will still return the field descriptor instead of None.

I'll use this issue as a marker for that