Vulcan/packages/vulcan-payments/lib/server/mutations.js

27 lines
884 B
JavaScript
Raw Normal View History

2017-07-13 17:37:59 +09:00
import { addGraphQLSchema, addGraphQLResolvers, addGraphQLMutation, Collections } from 'meteor/vulcan:core';
2017-05-31 10:25:13 +09:00
// import Users from 'meteor/vulcan:users';
import { createCharge } from '../server/integrations/stripe.js';
const resolver = {
Mutation: {
async createChargeMutation(root, args, context) {
return await createCharge(args);
},
},
};
2017-07-13 17:37:59 +09:00
addGraphQLResolvers(resolver);
addGraphQLMutation('createChargeMutation(token: JSON, userId: String, productKey: String, associatedCollection: String, associatedId: String, properties: JSON) : Chargeable');
2017-05-31 10:25:13 +09:00
const chargeableSchema = `
union Chargeable = ${Collections.map(collection => collection.typeName).join(' | ')}
`;
2017-07-13 17:37:59 +09:00
addGraphQLSchema(chargeableSchema);
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);