mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 04:26:41 -04:00
27 lines
No EOL
900 B
JavaScript
27 lines
No EOL
900 B
JavaScript
import { addGraphQLSchema, addGraphQLResolvers, addGraphQLMutation, Collections } 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');
|
|
|
|
const chargeableSchema = `
|
|
union Chargeable = ${Collections.map(collection => collection.typeName).join(' | ')}
|
|
`;
|
|
addGraphQLSchema(chargeableSchema);
|
|
|
|
const resolverMap = {
|
|
Chargeable: {
|
|
__resolveType(obj, context, info){
|
|
return obj.__typename || null;
|
|
},
|
|
},
|
|
};
|
|
addGraphQLResolvers(resolverMap); |