Open
Description
Hi,
I have read the documentation around data loaders from your site, but I can't make them to work.
I followed exactly your examples but when I run the Query I get:
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
/Users/alexandrubese/Documents/work/banking_api/venv/lib/python3.10/site-packages/graphql/execution/execute.py:431: RuntimeWarning: coroutine 'Query.resolve_account' was never awaited
result = self.execute_field(
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
account_dataloader.py
from aiodataloader import DataLoader
from core.models import Account
def get_account(id):
return Account.objects.get(pk=id)
class AccountLoader(DataLoader):
async def batch_load_fn(self, keys):
return [get_account(id=key) for key in keys]
schema.py
class Account(ObjectType):
id = ID()
name = String()
email = String()
city = String()
canton = String()
toy_category_preference = List(Int)
toy_size_preference = List(Int)
class Query(ObjectType):
hello = String(default_value="Hi!")
account = Field(Account, id=ID(required=True))
async def resolve_account(root, info, id):
account_data = await AccountLoader().load(id)
return account_data
What am I doing wrong?