mirror of
https://github.com/wassname/talk.git
synced 2026-07-16 11:22:16 +08:00
Adds graph functionality for plugins
This commit is contained in:
@@ -5,6 +5,7 @@ import isEqual from 'lodash/isEqual';
|
||||
import I18n from 'coral-framework/modules/i18n/i18n';
|
||||
import translations from 'coral-framework/translations';
|
||||
const lang = new I18n(translations);
|
||||
import {graphImporter} from 'coral-framework/helpers/importer';
|
||||
|
||||
import {TabBar, Tab, TabContent, Spinner} from 'coral-ui';
|
||||
|
||||
@@ -277,5 +278,6 @@ export default compose(
|
||||
addCommentTag,
|
||||
removeCommentTag,
|
||||
deleteAction,
|
||||
queryStream
|
||||
queryStream,
|
||||
...graphImporter
|
||||
)(Embed);
|
||||
|
||||
@@ -103,9 +103,23 @@ function reducersImporter () {
|
||||
return importAll(require.context('plugins', true, /\.\/(.*)\/client\/reducer.js$/));
|
||||
}
|
||||
|
||||
function graphImporter () {
|
||||
const context = require.context('plugins', true, /\.\/(.*)\/client\/(queries|mutations)\/index.js$/);
|
||||
return context
|
||||
.keys()
|
||||
.map(key => shapeData(key))
|
||||
.reduce((entry, actionsPlugin) => {
|
||||
const input = context(actionsPlugin.key);
|
||||
const res = Object.keys(input)
|
||||
.map(key => input[key]);
|
||||
return [...entry, ...res];
|
||||
}, []);
|
||||
}
|
||||
|
||||
export default {
|
||||
importer,
|
||||
actionsImporter: actionsImporter(),
|
||||
reducersImporter: reducersImporter()
|
||||
reducersImporter: reducersImporter(),
|
||||
graphImporter: graphImporter()
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import {graphql} from 'react-apollo';
|
||||
import POST_RESPECT from './postRespect.graphql';
|
||||
|
||||
export const postRespect = graphql(POST_RESPECT, {
|
||||
props: ({mutate}) => ({
|
||||
postRespect: (respect) => {
|
||||
return mutate({
|
||||
variables: {
|
||||
respect
|
||||
}
|
||||
});
|
||||
}})
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
mutation CreateRespect ($respect: CreateRespectInput!) {
|
||||
createRespect(respect: $respect) {
|
||||
respect {
|
||||
id
|
||||
}
|
||||
errors {
|
||||
translation_key
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,12 @@
|
||||
const typeDefs = require('./server/typeDefs');
|
||||
|
||||
module.exports = {
|
||||
typeDefs
|
||||
};
|
||||
typeDefs,
|
||||
resolvers: {
|
||||
RootMutation: {
|
||||
createRespect(_, {respect: {item_id, item_type}}, {mutators: {Action}}) {
|
||||
return Action.create({item_id, item_type, action_type: 'RESPECT'});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user