Created
February 23, 2020 06:14
-
-
Save austincollinpena/3044c6fc4e7e36a1ba0a5cb552b1e28b to your computer and use it in GitHub Desktop.
Pass an argument to a function via a graqphql mutation and return a new value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Packages: Django-graphene, django | |
from graphene_django.types import DjangoObjectType | |
import graphene | |
class FetchTwilioToken(graphene.Mutation): | |
# Define the arguments that are passed from the client in the mutation | |
class Arguments: | |
identity = graphene.String(required=True) | |
# Define the arguments that might be returned that are not defined | |
# elsewhere. Give them a graphene type | |
new_token = graphene.String() | |
def mutate(self, info, identity): | |
# These two lines of code are just grabbing a JWT via an internal | |
# package | |
new_token_getter = GetTwilioAuthToken(identity) | |
new_token = new_token_getter.fetchToken() | |
return FetchTwilioToken(new_token=new_token) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment