graphene icon indicating copy to clipboard operation
graphene copied to clipboard

Update dataloader docs to use aiodataloader

Open jkimbo opened this issue 4 years ago • 3 comments

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.

jkimbo avatar Apr 26 '20 11:04 jkimbo

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.

nerdstrike avatar May 27 '20 15:05 nerdstrike

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

asia653 avatar Oct 25 '21 23:10 asia653

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.

cpmsmith avatar Apr 18 '22 17:04 cpmsmith