graphene
graphene copied to clipboard
Update dataloader docs to use aiodataloader
graphql-core dropped support for the Promise library (since asyncio is now the official way to do async code in Python). @syrusakbary has already created an asyncio version of dataloader: https://github.com/syrusakbary/aiodataloader . We should update the documentation.
Just to note that aiodataloader seems to be unmaintained at this time. I put in a request to remove a deprecated python import months ago and it has gone neglected.
user1_future = user_loader.load(1)
user2_future = user_loader.load(2)
user1 = await user1_future
user2 = await user2_future
user1_invitedby = user_loader.load(user1.invited_by_id)
user2_invitedby = user_loader.load(user2.invited_by_id)
print("User 1 was invited by", await user1_invitedby)
print("User 2 was invited by", await user2_invitedby)
Is this code in the docs correct? According to the codebase, dataloader returns a Promise that resolves into an array of values, so awaiting the future should return an array with a single value
Just to note that aiodataloader seems to be unmaintained at this time. I put in a request to remove a deprecated python import months ago and it has gone neglected.
Note to onlookers: the PR mentioned here, syrusakbary/aiodataloader#11, has since been merged, and aiodataloader released a version on 2022-01-24.