mirror of
https://github.com/wassname/talk.git
synced 2026-07-07 09:53:01 +08:00
38 lines
882 B
JavaScript
38 lines
882 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: {
|
|
createLove(_, {love: {item_id, item_type}}, {mutators: {Action}}) {
|
|
return wrapResponse('love')(Action.create({item_id, item_type, action_type: 'LOVE'}));
|
|
}
|
|
}
|
|
},
|
|
hooks: {
|
|
Action: {
|
|
__resolveType: {
|
|
post({action_type}) {
|
|
switch (action_type) {
|
|
case 'LOVE':
|
|
return 'LoveAction';
|
|
}
|
|
}
|
|
}
|
|
},
|
|
ActionSummary: {
|
|
__resolveType: {
|
|
post({action_type}) {
|
|
switch (action_type) {
|
|
case 'LOVE':
|
|
return 'LoveActionSummary';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|