Created
October 8, 2020 07:56
-
-
Save rob-blackbourn/246139a0bb0d8659cc981b57602f828b to your computer and use it in GitHub Desktop.
Graphene 3 example mutation
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
import typing | |
import graphene | |
from jetblack_tweeter import Tweeter | |
from ..types import TweetType | |
class UpdateStatus(graphene.Mutation): | |
class Arguments: | |
status = graphene.String() | |
Output = TweetType | |
@staticmethod | |
async def mutate(root, info, status: str) -> typing.Mapping[str, typing.Any]: | |
tweeter: Tweeter = info.context['tweeter'] | |
tweet = await tweeter.statuses.update(status) | |
return tweet | |
class Mutations(graphene.ObjectType): | |
update_status = UpdateStatus.Field() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment