Adding fragment views

This commit is contained in:
Belen Curcio
2017-01-25 07:09:11 -03:00
parent b1848c28e4
commit cebc5f2f45
6 changed files with 42 additions and 14 deletions
+32
View File
@@ -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,
@@ -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 */ ) => {
@@ -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
@@ -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
}
})
});
@@ -1,3 +1,5 @@
#import "../fragments/commentView.graphql"
query AssetQuery($asset_url: String!) {
asset(url: $asset_url) {
id
-12
View File
@@ -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
};