mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 04:26:41 -04:00
31 lines
No EOL
1 KiB
JavaScript
31 lines
No EOL
1 KiB
JavaScript
import { addGraphQLSchema, addGraphQLResolvers, addGraphQLMutation, Collections, addCallback } from 'meteor/vulcan:core';
|
|
// 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);
|
|
},
|
|
},
|
|
};
|
|
addGraphQLResolvers(resolver);
|
|
addGraphQLMutation('createChargeMutation(token: JSON, userId: String, productKey: String, associatedCollection: String, associatedId: String, properties: JSON, coupon: String) : Chargeable');
|
|
|
|
function CreateChargeableUnionType() {
|
|
const chargeableSchema = `
|
|
union Chargeable = ${Collections.map(collection => collection.typeName).join(' | ')}
|
|
`;
|
|
addGraphQLSchema(chargeableSchema);
|
|
return {}
|
|
}
|
|
addCallback('graphql.init.before', CreateChargeableUnionType);
|
|
|
|
const resolverMap = {
|
|
Chargeable: {
|
|
__resolveType(obj, context, info){
|
|
return obj.__typename || null;
|
|
},
|
|
},
|
|
};
|
|
addGraphQLResolvers(resolverMap); |