mirror of
https://github.com/wassname/talk.git
synced 2026-07-03 21:49:36 +08:00
e0a3e8a3c1
Conflicts: plugins/coral-plugin-respect/index.js
37 lines
897 B
JavaScript
37 lines
897 B
JavaScript
const {readFileSync} = require('fs');
|
|
const path = require('path');
|
|
const wrapResponse = require('../../graph/helpers/response');
|
|
|
|
module.exports = {
|
|
typeDefs: readFileSync(path.join(__dirname, 'server/typeDefs.graphql'), 'utf8'),
|
|
resolvers: {
|
|
RootMutation: {
|
|
createRespect(_, {respect: {item_id, item_type}}, {mutators: {Action}}) {
|
|
return wrapResponse('respect')(Action.create({item_id, item_type, action_type: 'RESPECT'}));
|
|
}
|
|
}
|
|
},
|
|
hooks: {
|
|
Action: {
|
|
__resolveType: {
|
|
post({action_type}) {
|
|
switch (action_type) {
|
|
case 'RESPECT':
|
|
return 'RespectAction';
|
|
}
|
|
}
|
|
}
|
|
},
|
|
ActionSummary: {
|
|
__resolveType: {
|
|
post({action_type}) {
|
|
switch (action_type) {
|
|
case 'RESPECT':
|
|
return 'RespectActionSummary';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|