Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'SyncFuture' object has no attribute 'then' #9

Open
JhonRobert20 opened this issue Nov 14, 2022 · 3 comments
Open

'SyncFuture' object has no attribute 'then' #9

JhonRobert20 opened this issue Nov 14, 2022 · 3 comments

Comments

@JhonRobert20
Copy link

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

@MPickfield
Copy link

@jkimbo Looks like support for future chaining (as documented in the readme) hasn't been released yet.

@mahdyhamad
Copy link

any update regarding this issue?

@androane
Copy link

Bump. I get the same error. Why is it not working but documented in the README as working?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants