Repository: strawberry-graphql/strawberry

Issue:
`strawberry.field` does not type check properly for async resolvers, but `strawberry.field()` does
## Describe the Bug

An example speaks a thousand words. Given the following minimal test case:

```python
import strawberry
from django.test import SimpleTestCase


@strawberry.type
class Example:
    @strawberry.field
    async def async_field_1(self) -> str:
        return "str 1"

    @strawberry.field()
    async def async_field_2(self) -> str:
        return "str 2"


class ExampleTest(SimpleTestCase):
    async def test_types(self):
        example = Example()

        self.assertEqual(await example.async_field_1(), "str 1")
        self.assertEqual(await example.async_field_2(), "str 2")
```

* the only difference between async_field_1 and async_field_2 is the parentheses after the `strawberry.field` annotation
* the test passes (demonstrated by green checkmark)
* the first assertion does not pass type check (demonstrated by red squiggly). The second one does.

Screenshot:
<img width="762" alt="Screenshot 2023-09-01 at 12 38 27" src="https://github.com/strawberry-graphql/strawberry/assets/75862/808048a1-a926-437b-8321-6e6e3b13e2f0">

The problem shows up as "async_field_1 is not awaitable" (if the field has args), or "missing argument for parameter resolver" (if the field has no args)


## System Information

 - Strawberry version: 0.204.0



<!-- POLAR PLEDGE BADGE START -->
## Upvote & Fund

- We're using [Polar.sh](https://polar.sh/strawberry-graphql) 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.

<a href="https://polar.sh/strawberry-graphql/strawberry/issues/3071">
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://polar.sh/api/github/strawberry-graphql/strawberry/issues/3071/pledge.svg?darkmode=1">
  <img alt="Fund with Polar" src="https://polar.sh/api/github/strawberry-graphql/strawberry/issues/3071/pledge.svg">
</picture>
</a>
<!-- POLAR PLEDGE BADGE END -->



Discussion:
hi @ben-xo! it this mypy or pyright?


> hi @ben-xo! it this mypy or pyright?

It's coming up as Pylance within VSCode so I guess it must be pyright. Our mypy config seems ok with it.
Here are the two variations
<img width="960" alt="Screenshot 2023-09-01 at 12 52 37" src="https://github.com/strawberry-graphql/strawberry/assets/75862/0ab752e6-101a-4b72-87f6-c9808102266b">
<img width="1024" alt="Screenshot 2023-09-01 at 12 40 35" src="https://github.com/strawberry-graphql/strawberry/assets/75862/4c9f7494-dc4a-4f8a-9033-c483748ad168">


Resolving patch:
diff --git a/strawberry/field.py b/strawberry/field.py
--- a/strawberry/field.py
+++ b/strawberry/field.py
@@ -49,7 +49,7 @@
 _RESOLVER_TYPE = Union[
     StrawberryResolver[T],
     Callable[..., T],
-    Callable[..., Coroutine[T, Any, Any]],
+    Callable[..., Coroutine[Any, Any, T]],
     Callable[..., Awaitable[T]],
     "staticmethod[Any, T]",
     "classmethod[Any, Any, T]",


Test patch:
diff --git a/tests/mypy/test_fields.yml b/tests/mypy/test_fields.yml
--- a/tests/mypy/test_fields.yml
+++ b/tests/mypy/test_fields.yml
@@ -128,3 +128,31 @@
     reveal_type(i.a)
   out: |
     main:14: note: Revealed type is "builtins.str"
+
+- case: test_mismatched_annotations_sync_resolver
+  main: |
+    import strawberry
+
+    def some_resolver() -> int:
+        return 0
+
+    @strawberry.type
+    class User:
+        name: str = strawberry.field(resolver=some_resolver)
+
+  out: |
+    main:8: error: Incompatible types in assignment (expression has type "int", variable has type "str")  [assignment]
+
+- case: test_mismatched_annotations_async_resolver
+  main: |
+    import strawberry
+
+    async def some_resolver() -> int:
+        return 0
+
+    @strawberry.type
+    class User:
+        name: str = strawberry.field(resolver=some_resolver)
+
+  out: |
+    main:8: error: Incompatible types in assignment (expression has type "int", variable has type "str")  [assignment]
diff --git a/tests/pyright/test_fields_resolver_async.py b/tests/pyright/test_fields_resolver_async.py
--- a/tests/pyright/test_fields_resolver_async.py
+++ b/tests/pyright/test_fields_resolver_async.py
@@ -13,6 +13,7 @@ async def get_user_age() -> int:
 class User:
     name: str
     age: int = strawberry.field(resolver=get_user_age)
+    something: str = strawberry.field(resolver=get_user_age)
 
 
 User(name="Patrick")
@@ -27,28 +28,38 @@ def test_pyright():
     results = run_pyright(CODE)
 
     assert results == [
+        Result(
+            type="error",
+            message=(
+                'Expression of type "StrawberryField" is incompatible with '
+                'declared type "str"\n'
+                '\xa0\xa0"StrawberryField" is incompatible with "str"'
+            ),
+            line=12,
+            column=22,
+        ),
         Result(
             type="error",
             message='Argument missing for parameter "name"',
-            line=15,
+            line=16,
             column=1,
         ),
         Result(
             type="error",
             message='No parameter named "n"',
-            line=15,
+            line=16,
             column=6,
         ),
         Result(
             type="information",
             message='Type of "User" is "type[User]"',
-            line=17,
+            line=18,
             column=13,
         ),
         Result(
             type="information",
             message='Type of "User.__init__" is "(self: User, *, name: str) -> None"',
-            line=18,
+            line=19,
             column=13,
         ),
     ]