2017-08-29 17:57:04 +09:00
|
|
|
import { addGraphQLSchema, addGraphQLResolvers, addGraphQLMutation, Collections, addCallback } from 'meteor/vulcan:core';
|
2017-05-31 10:25:13 +09:00
|
|
|
// import Users from 'meteor/vulcan:users';
|
2018-04-07 10:10:09 +09:00
|
|
|
import { receiveAction } from '../server/integrations/stripe.js';
|
2017-05-31 10:25:13 +09:00
|
|
|
|
|
|
|
const resolver = {
|
|
|
|
Mutation: {
|
2017-10-18 20:05:51 +09:00
|
|
|
async paymentActionMutation(root, args, context) {
|
2018-04-07 10:10:09 +09:00
|
|
|
return await receiveAction(args);
|
2017-05-31 10:25:13 +09:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2017-07-13 17:37:59 +09:00
|
|
|
addGraphQLResolvers(resolver);
|
2017-10-18 20:05:51 +09:00
|
|
|
addGraphQLMutation('paymentActionMutation(token: JSON, userId: String, productKey: String, associatedCollection: String, associatedId: String, properties: JSON, coupon: String) : Chargeable');
|
2017-05-31 10:25:13 +09:00
|
|
|
|
2017-08-29 17:57:04 +09:00
|
|
|
function CreateChargeableUnionType() {
|
|
|
|
const chargeableSchema = `
|
|
|
|
union Chargeable = ${Collections.map(collection => collection.typeName).join(' | ')}
|
|
|
|
`;
|
|
|
|
addGraphQLSchema(chargeableSchema);
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
addCallback('graphql.init.before', CreateChargeableUnionType);
|
2017-05-31 10:25:13 +09:00
|
|
|
|
|
|
|
const resolverMap = {
|
|
|
|
Chargeable: {
|
|
|
|
__resolveType(obj, context, info){
|
|
|
|
return obj.__typename || null;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2017-07-13 17:37:59 +09:00
|
|
|
addGraphQLResolvers(resolverMap);
|