Skip to content

Instantly share code, notes, and snippets.

@rob-blackbourn
Created October 8, 2020 07:56
Show Gist options
  • Save rob-blackbourn/246139a0bb0d8659cc981b57602f828b to your computer and use it in GitHub Desktop.
Save rob-blackbourn/246139a0bb0d8659cc981b57602f828b to your computer and use it in GitHub Desktop.
Graphene 3 example mutation
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