From e993330467d9f6050c4e77c3c2fef3b70b938327 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 25 Jan 2017 05:20:34 -0300 Subject: [PATCH] Adding fragments :tada: --- .../src/graphql/fragments/commentView.graphql | 20 +++++++++++++++++++ .../src/graphql/mutations/index.js | 5 +++++ .../src/graphql/mutations/postComment.graphql | 18 ----------------- 3 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 client/coral-embed-stream/src/graphql/fragments/commentView.graphql diff --git a/client/coral-embed-stream/src/graphql/fragments/commentView.graphql b/client/coral-embed-stream/src/graphql/fragments/commentView.graphql new file mode 100644 index 000000000..b54c00e67 --- /dev/null +++ b/client/coral-embed-stream/src/graphql/fragments/commentView.graphql @@ -0,0 +1,20 @@ +fragment commentView on Comment { + id + body + created_at + user { + id + name: displayName + settings { + bio + } + } + actions { + type: action_type + count + current: current_user { + id + created_at + } + } +} diff --git a/client/coral-embed-stream/src/graphql/mutations/index.js b/client/coral-embed-stream/src/graphql/mutations/index.js index 383862455..5fbfbf9d2 100644 --- a/client/coral-embed-stream/src/graphql/mutations/index.js +++ b/client/coral-embed-stream/src/graphql/mutations/index.js @@ -3,7 +3,12 @@ import POST_COMMENT from './postComment.graphql'; import POST_ACTION from './postAction.graphql'; import DELETE_ACTION from './deleteAction.graphql'; +import commentView from '../fragments/commentView.graphql'; + export const postComment = graphql(POST_COMMENT, { + options: () => ({ + fragments: [commentView] + }), props: ({mutate}) => ({ postItem: ({asset_id, body, parent_id} /* , type */ ) => { return mutate({ diff --git a/client/coral-embed-stream/src/graphql/mutations/postComment.graphql b/client/coral-embed-stream/src/graphql/mutations/postComment.graphql index a9496f1fa..46ef879ce 100644 --- a/client/coral-embed-stream/src/graphql/mutations/postComment.graphql +++ b/client/coral-embed-stream/src/graphql/mutations/postComment.graphql @@ -1,21 +1,3 @@ - - fragment commentView on Comment { - id - body - status - user { - name: displayName - } - actions { - type: action_type - count - current: current_user { - id - created_at - } - } - } - mutation CreateComment ($asset_id: ID!, $parent_id: ID, $body: String!) { createComment(asset_id:$asset_id, parent_id:$parent_id, body:$body) { ...commentView