Random mutation

alexandr_lebedev

python (django)

graphene mutation:
другие самплы
class LikeMutation(AutoDocMutationMixin, graphene.Mutation):
    """:::
    postId: number
    """

    class Arguments:
        post_id = graphene.ID(required=True)

    increased = graphene.Boolean()  # fields must be a mapping (dict / OrderedDict)

    @classmethod
    def mutate(cls, root, info, post_id):
        deleted, _ = Like.objects.filter(target_id=post_id, author=info.context.user).delete()
        created = not deleted and (
            Like.objects.create(target_id=post_id, author=info.context.user)
        )
        return LikeMutation(increased=bool(created))
(ваш голос учтен)

Прикрепить файл