From d03583df5ed7c35f4468ce6fd515a0b4e9bad1a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bel=C3=A9n=20Curcio?= Date: Tue, 25 Sep 2018 19:05:27 -0300 Subject: [PATCH] Adding Delete Reaction --- .../DeleteCommentReactionMutation.ts | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/core/client/stream/mutations/DeleteCommentReactionMutation.ts diff --git a/src/core/client/stream/mutations/DeleteCommentReactionMutation.ts b/src/core/client/stream/mutations/DeleteCommentReactionMutation.ts new file mode 100644 index 000000000..3c1967ee5 --- /dev/null +++ b/src/core/client/stream/mutations/DeleteCommentReactionMutation.ts @@ -0,0 +1,49 @@ +import { graphql } from "react-relay"; +import { Environment } from "relay-runtime"; + +import { + commitMutationPromiseNormalized, + createMutationContainer, +} from "talk-framework/lib/relay"; + +import { DeleteCommentReactionMutation as MutationTypes } from "talk-stream/__generated__/DeleteCommentReactionMutation.graphql"; +import { CreateCommentReactionInput } from "./CreateCommentReactionMutation"; + +const mutation = graphql` + mutation DeleteCommentReactionMutation($input: CreateCommentReactionInput!) { + deleteCommentReaction(input: $input) { + comment { + id + actionCounts { + reaction { + total + } + } + } + clientMutationId + } + } +`; + +const clientMutationId = 0; + +function commit(environment: Environment, input: CreateCommentReactionInput) { + return commitMutationPromiseNormalized(environment, { + mutation, + variables: { + input: { + ...input, + clientMutationId: clientMutationId.toString(), + }, + }, + }); +} + +export const withDeleteCommentReactionMutation = createMutationContainer( + "deleteCommentReaction", + commit +); + +export type DeleteCommentReactionMutation = ( + input: CreateCommentReactionInput +) => Promise;