Repository: strawberry-graphql/strawberry

Issue:
Can't get DataLoader to work
Hello! I'm trying examples from this page https://strawberry.rocks/docs/guides/dataloaders.
Running the following code on Python 3.8:
```python
import strawberry
from strawberry.dataloader import DataLoader
from typing import List


@strawberry.type
class User:
    id: strawberry.ID


async def load_users(keys) -> List[User]:
    return [User(id=key) for key in keys]

loader = DataLoader(load_fn=load_users)


@strawberry.type
class Query:
    @strawberry.field
    async def get_user(self, id: strawberry.ID) -> User:
        return await loader.load(id)


schema = strawberry.Schema(query=Query)
```
I get the following error message:
```
Task <Task pending name='Task-8' coro=<ExecutionContext.resolve_field.<locals>.await_result() 
running at /Users/-/Documents/src/dataservice-poc/virtualenv/lib/python3.8/site-packages/graphql/execution/execute.py:625> 
cb=[gather.<locals>._done_callback() at /usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/tasks.py:758]> 
got Future <Future pending> attached to a different loop
```

When I try my own code (which is pretty much the same, but the loader is real - it reads data from the db) I get this: "RuntimeError: await wasn't used with future".

I'm stuck, don't really know where to look. I thought Strawberry is supposed to manage async processing, but looks like it doesn't work that way. Any help would be greatly appreciated.


Discussion:
What are you using to run the server?

Just yesterday I implemented dataloaders in a project and it worked without any issue, some links as example:

dataloader: https://github.com/pythonitalia/pycon/blob/master/users-backend/users/api/dataloader.py
usage: https://github.com/pythonitalia/pycon/blob/master/users-backend/users/api/types.py#L58

Whatever is used as a debug server in examples. I've just started using Strawberry and the fact that examples are not working is quite.. misleading. I'll try checking out your code, thanks.
I think the problem is that the DataLoader object is created before the debug servers asyncio loop. This needs some extra research though. I agree examples in the documentation should work when copy pasted.

The following example might look a little inpractical but it works. Note that the docs recomment [creating the dataloader when creating the GraphQL context](https://strawberry.rocks/docs/guides/dataloaders#usage-with-context). This would work around the issue as well.

```python
import strawberry
from strawberry.dataloader import DataLoader
from typing import List


@strawberry.type
class User:
    id: strawberry.ID


async def load_users(keys) -> List[User]:
    return [User(id=key) for key in keys]


@strawberry.type
class Query:
    @strawberry.field
    async def get_user(self, id: strawberry.ID) -> User:
        loader = DataLoader(load_fn=load_users)
        return await loader.load(id)


schema = strawberry.Schema(query=Query)
```

Resolving patch:
diff --git a/strawberry/cli/commands/server.py b/strawberry/cli/commands/server.py
--- a/strawberry/cli/commands/server.py
+++ b/strawberry/cli/commands/server.py
@@ -57,4 +57,4 @@ def server(schema, host, port, app_dir):
         app.add_websocket_route(path, graphql_app)
 
     print(f"Running strawberry on http://{host}:{port}/ 🍓")
-    uvicorn.run(app, host=host, port=port, log_level="error")
+    uvicorn.run(app, loop="none", host=host, port=port, log_level="error")


Test patch: