diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index 87ab32fa3..bfb09857c 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -1,4 +1,5 @@ import React, {Component} from 'react'; +import gql from 'graphql-tag'; import {compose} from 'react-apollo'; import {connect} from 'react-redux'; import {isEqual} from 'lodash'; @@ -195,6 +196,37 @@ const mapDispatchToProps = dispatch => ({ dispatch: d => dispatch(d) }); +// import commentView from './graphql/fragments/commentView.graphql'; +// +// Embed.fragments = { +// entry: commentView +// }; + +Embed.fragments = { + entry: gql` + 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 + } + } + } + `, +}; + export default compose( connect(mapStateToProps, mapDispatchToProps), postComment, diff --git a/client/coral-embed-stream/src/graphql/mutations/index.js b/client/coral-embed-stream/src/graphql/mutations/index.js index 5fbfbf9d2..b97e5ff22 100644 --- a/client/coral-embed-stream/src/graphql/mutations/index.js +++ b/client/coral-embed-stream/src/graphql/mutations/index.js @@ -7,7 +7,7 @@ import commentView from '../fragments/commentView.graphql'; export const postComment = graphql(POST_COMMENT, { options: () => ({ - fragments: [commentView] + fragments: commentView }), props: ({mutate}) => ({ postItem: ({asset_id, body, parent_id} /* , type */ ) => { diff --git a/client/coral-embed-stream/src/graphql/mutations/postComment.graphql b/client/coral-embed-stream/src/graphql/mutations/postComment.graphql index 46ef879ce..499871766 100644 --- a/client/coral-embed-stream/src/graphql/mutations/postComment.graphql +++ b/client/coral-embed-stream/src/graphql/mutations/postComment.graphql @@ -1,3 +1,5 @@ +#import "../fragments/commentView.graphql" + mutation CreateComment ($asset_id: ID!, $parent_id: ID, $body: String!) { createComment(asset_id:$asset_id, parent_id:$parent_id, body:$body) { ...commentView diff --git a/client/coral-embed-stream/src/graphql/queries/index.js b/client/coral-embed-stream/src/graphql/queries/index.js index ae01ea9f4..0bdc6cdaf 100644 --- a/client/coral-embed-stream/src/graphql/queries/index.js +++ b/client/coral-embed-stream/src/graphql/queries/index.js @@ -5,5 +5,9 @@ import pym from 'coral-framework/PymConnection'; let url = pym.parentUrl.split('#')[0] || 'http://localhost:3000/'; export const queryStream = graphql(STREAM_QUERY, { - options: {variables: {asset_url: url}} + options: () => ({ + variables: { + asset_url: url + } + }) }); diff --git a/client/coral-embed-stream/src/graphql/queries/streamQuery.graphql b/client/coral-embed-stream/src/graphql/queries/streamQuery.graphql index 5c5018d41..77f8ed356 100644 --- a/client/coral-embed-stream/src/graphql/queries/streamQuery.graphql +++ b/client/coral-embed-stream/src/graphql/queries/streamQuery.graphql @@ -1,3 +1,5 @@ +#import "../fragments/commentView.graphql" + query AssetQuery($asset_url: String!) { asset(url: $asset_url) { id diff --git a/client/coral-framework/actions/user.js b/client/coral-framework/actions/user.js index a9bf0546a..4620262d3 100644 --- a/client/coral-framework/actions/user.js +++ b/client/coral-framework/actions/user.js @@ -1,5 +1,4 @@ import * as actions from '../constants/user'; -import * as assetActions from '../constants/assets'; import {addNotification} from '../actions/notification'; import coralApi from '../helpers/response'; @@ -20,14 +19,3 @@ export const saveBio = (user_id, formData) => dispatch => { }) .catch(error => dispatch(saveBioFailure(error))); }; - -/** - * - * Get a list of comments by a single user - * - * @param {string} user_id - * @returns Promise - */ -export const fetchCommentsByUserId = userId => { - // TODO -};