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

when I add class Arguments: the original arguments disappeared? #23

Open
aliscie opened this issue Mar 17, 2021 · 1 comment
Open

when I add class Arguments: the original arguments disappeared? #23

aliscie opened this issue Mar 17, 2021 · 1 comment

Comments

@aliscie
Copy link

aliscie commented Mar 17, 2021

I need to create the following custom class mutation , in order to create users if they are not aready exists. To do that I need to pas arguments from the forest end like username, password.....
So I tried this .

class SocialAuth(graphql_social_auth.SocialAuthJWT):
    # class Arguments:
    #     id = graphene.Int(required=False)
    user = graphene.Field(schema.Users)

    @classmethod
    def resolve(cls, root, info, social, **kwargs):
        try:
            user = models.ExtendUser.objects.get(email=social.uid)
            return cls(user=user)
        except:
            # TODO use profileObj. get username email and all these and add them kwargs
            user = models.ExtendUser.objects.create(
                email=social.uid, username=social.uid[0:6], password="AAssppmm11", imageUrl="https://miro.medium.com/max/1200/1*mk1-6aYaf_Bes1E3Imhc0A.jpeg")
            return cls(user=user)

But adding class Arguments: make the arguments provider and accessToken disappear.

an other problem is the token return null in the costum class mutation, while is working very well in the social_auth = graphql_social_auth.SocialAuthJWT.Field()

@osvalros
Copy link

osvalros commented May 3, 2021

I think this is because the way Python works - the new class Arguments replaces the original one and doesnt inherit from it. You need to do it manually. In this case you would define it like this:
class Arguments(graphql_social_auth.SocialAuthJWT.Arguments)
Maybe you could use the super builtin instead of the whole class name to shorten it and make more universal. Hope that helps.

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

2 participants