graphql-sync-dataloaders
graphql-sync-dataloaders copied to clipboard
'SyncFuture' object has no attribute 'then'
Hello, I'm having problems with the dataloaders in a project where I use strawberry for the subscriptions and Graphene for the mutations and queries. The problem is that I'm trying to use the 'then' inside a resolver but raise an error: "'SyncFuture' object has no attribute 'then'".
Explanation
The resolver is:
def resolve_creator(self, info):
if not self.creator:
return None
if hasattr(info.context, "loaders"):
return info.context.loaders.user_community_loader.load(
self.creator_id
).then(lambda user: user)
return self.creator
The loader was charged inside the info context
self.user_community_loader = SyncDataLoader(user_community_load)
And the user community load follows your example:
def user_community_load(keys: List[int]) -> List[UserCommunity]:
qs = UserCommunity.objects.filter(id__in=keys)
user_map = {user.id: user for user in qs}
return [user_map.get(key, None) for key in keys]
Requirements
# django
Django==4.1.2
graphene-django>=3.0.0
python-dotenv==0.21.0
django-storages==1.13.1
django-graphql-jwt==0.3.4
urllib3==1.26.12
djangorestframework==3.14.0
PyJWT==2.6.0
str2bool==1.1
requests==2.27.1
# postgreSQL
psycopg2-binary==2.9.4
# Celery
django-redis==5.2.0
celery[redis]==5.2.7
django-celery-beat==2.4.0
# Pillow
pillow==9.2.0
# uWSGI
uWSGI==2.0.20
# Cors
django-cors-headers==3.13.0
# AWS
boto3==1.24.96
# Crypto
jwcrypto==1.4.2
ecdsa==0.17.0
base58==2.1.1
siwe==2.0.0
#Sentry
sentry-sdk==1.6.0
# Pubnub
pubnub==7.0.0
# Export
django-import-export==3.0.1
# Strawberry channels
strawberry-graphql[channels]==0.128.0
channels-redis==3.4.1
# Dataloaders
graphql-sync-dataloaders==0.1.1
If you have any idea of why is this error raising please let me know, thanks a lot
@jkimbo Looks like support for future chaining (as documented in the readme) hasn't been released yet.
any update regarding this issue?
Bump. I get the same error. Why is it not working but documented in the README as working?!