mirror of
https://github.com/wassname/talk.git
synced 2026-07-25 13:30:59 +08:00
queries and mutations
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import React, {Component, PropTypes} from 'react';
|
||||
import Pym from 'pym.js';
|
||||
import {graphql, compose} from 'react-apollo';
|
||||
import {compose} from 'react-apollo';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import STREAM_QUERY from './graphql/queries/streamQuery.graphql';
|
||||
import POST_COMMENT from './graphql/mutations/postComment.graphql';
|
||||
import {postComment} from './graphql/mutations'
|
||||
import {queryStream} from './graphql/queries'
|
||||
|
||||
import {
|
||||
|
||||
@@ -209,6 +209,7 @@ const mapDispatchToProps = dispatch => ({
|
||||
// appendItemArray: (item, property, value, addToFront, itemType) => dispatch(appendItemArray(item, property, value, addToFront, itemType)),
|
||||
// handleSignInDialog: () => dispatch(authActions.showSignInDialog()),
|
||||
logout: () => dispatch(logout()),
|
||||
dispatch: d => dispatch(d)
|
||||
});
|
||||
|
||||
// Initialize GraphQL queries or mutations with the `gql` tag
|
||||
@@ -217,24 +218,7 @@ const pym = new Pym.Child({polling: 100});
|
||||
let url = pym.parentUrl;
|
||||
|
||||
export default compose(
|
||||
graphql(STREAM_QUERY, {
|
||||
options: {variables: {asset_url: url}},
|
||||
props: props => props,
|
||||
}),
|
||||
graphql(POST_COMMENT, {
|
||||
props: ({mutate}) => ({
|
||||
postItem: ({asset_id, body}) => {
|
||||
mutate({
|
||||
variables: {
|
||||
asset_id,
|
||||
body,
|
||||
parent_id: null
|
||||
}
|
||||
}).then(({data}) => {
|
||||
console.log('it workt');
|
||||
console.log(data);
|
||||
});
|
||||
}}),
|
||||
}),
|
||||
connect(mapStateToProps, mapDispatchToProps)
|
||||
connect(mapStateToProps, mapDispatchToProps),
|
||||
postComment(),
|
||||
queryStream()
|
||||
)(Embed);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { graphql } from 'react-apollo';
|
||||
import POST_COMMENT from './postComment.graphql';
|
||||
|
||||
export const postComment = () =>
|
||||
graphql(POST_COMMENT, {
|
||||
props: ({mutate}) => ({
|
||||
postItem: ({asset_id, body}) => {
|
||||
mutate({
|
||||
variables: {
|
||||
asset_id,
|
||||
body,
|
||||
parent_id: null
|
||||
}
|
||||
}).then(({data}) => {
|
||||
console.log('it workt');
|
||||
console.log(data);
|
||||
});
|
||||
}}),
|
||||
});
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { graphql } from 'react-apollo';
|
||||
import STREAM_QUERY from './streamQuery.graphql';
|
||||
import Pym from 'pym.js';
|
||||
|
||||
const pym = new Pym.Child({polling: 100});
|
||||
let url = pym.parentUrl;
|
||||
|
||||
export const queryStream = () =>
|
||||
graphql(STREAM_QUERY, {
|
||||
options: {variables: {asset_url: url}},
|
||||
props: props => props,
|
||||
});
|
||||
@@ -7,6 +7,13 @@ const Comment = {
|
||||
},
|
||||
actions({id}, _, {loaders}) {
|
||||
return loaders.Actions.getByID.load(id);
|
||||
},
|
||||
status({status}) {
|
||||
|
||||
// Because the status can be `null`, we do this check.
|
||||
if (status) {
|
||||
return status.toUpperCase();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ type Comment {
|
||||
user: User
|
||||
replies(limit: Int = 3): [Comment]
|
||||
actions: [ActionSummary]
|
||||
status: String
|
||||
}
|
||||
|
||||
enum ITEM_TYPE {
|
||||
|
||||
Reference in New Issue
Block a user