strawberry-graphql / strawberry-django

Strawberry GraphQL Django extension
https://strawberry.rocks/docs/django
MIT License
415 stars 120 forks source link

Unannotated `info` parameter in built-in resolver functions causes a `DeprecationWarning` #238

Closed linusg closed 1 year ago

linusg commented 1 year ago

Describe the Bug

When using some of the built-in resolver functions in strawberry-graphql-django with a current version of strawberry, a DeprecationWarning is emitted:

DeprecationWarning: Argument name-based matching of 'info' is deprecated and will be removed in v1.0. Ensure that reserved arguments are annotated their respective types (i.e. use value: 'DirectiveValue[str]' instead of 'value: str' and 'info: Info' instead of a plain 'info').

This affects at least the auth resolvers, possibly more:

https://github.com/strawberry-graphql/strawberry-graphql-django/blob/97cdea29867d33b2bfd75b67a4310dd6cc147ddc/strawberry_django/auth/queries.py#L4

https://github.com/strawberry-graphql/strawberry-graphql-django/blob/97cdea29867d33b2bfd75b67a4310dd6cc147ddc/strawberry_django/auth/mutations.py#L17

https://github.com/strawberry-graphql/strawberry-graphql-django/blob/97cdea29867d33b2bfd75b67a4310dd6cc147ddc/strawberry_django/auth/mutations.py#L28

The relevant upstream code is here:

https://github.com/strawberry-graphql/strawberry/blob/dfde19a386ca2ff4124d6bb2955df4fd771cdfb9/strawberry/types/fields/resolver.py#L122-L127

System Information

Python 3.11 strawberry-graphql 0.159.0 strawberry-graphql-django 0.9.2

Additional Context

It is possible to suppress the warning as it uses regular warnings module functionality, but considering this will stop working at some point in strawberry itself, this should be fixed.

Upvote & Fund

Fund with Polar

bellini666 commented 1 year ago

This was solved during the refactor done on v0.10.0 :)