@wepublish/api
Version:
API core for we.publish.
58 lines • 3.1 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GraphQLPublicSubscriptionInput = exports.GraphQLPublicSubscription = void 0;
const graphql_1 = require("graphql");
const graphql_scalars_1 = require("graphql-scalars");
const utility_1 = require("../utility");
const common_1 = require("./common");
const memberPlan_1 = require("./memberPlan");
const paymentMethod_1 = require("./paymentMethod");
const subscriptionDeactivation_1 = require("./subscriptionDeactivation");
exports.GraphQLPublicSubscription = new graphql_1.GraphQLObjectType({
name: 'Subscription',
fields: {
id: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID) },
memberPlan: {
type: new graphql_1.GraphQLNonNull(memberPlan_1.GraphQLPublicMemberPlan),
resolve({ memberPlanID }, args, { loaders }) {
return loaders.memberPlansByID.load(memberPlanID);
}
},
paymentPeriodicity: { type: new graphql_1.GraphQLNonNull(memberPlan_1.GraphQLPaymentPeriodicity) },
monthlyAmount: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLInt) },
autoRenew: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean) },
startsAt: { type: new graphql_1.GraphQLNonNull(graphql_scalars_1.GraphQLDateTime) },
paidUntil: { type: graphql_scalars_1.GraphQLDateTime },
paymentMethod: {
type: new graphql_1.GraphQLNonNull(paymentMethod_1.GraphQLPublicPaymentMethod),
resolve({ paymentMethodID }, args, { loaders }) {
return loaders.paymentMethodsByID.load(paymentMethodID);
}
},
properties: {
type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(common_1.GraphQLMetadataPropertyPublic))),
resolve: ({ properties }) => {
return properties.filter(property => property.public).map(({ key, value }) => ({ key, value }));
}
},
deactivation: { type: subscriptionDeactivation_1.GraphQLSubscriptionDeactivation },
url: {
type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
resolve: (0, utility_1.createProxyingResolver)((subscription, _, { urlAdapter }) => {
return urlAdapter.getSubscriptionURL(subscription);
})
}
}
});
exports.GraphQLPublicSubscriptionInput = new graphql_1.GraphQLInputObjectType({
name: 'SubscriptionInput',
fields: {
id: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID) },
memberPlanID: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
paymentPeriodicity: { type: new graphql_1.GraphQLNonNull(memberPlan_1.GraphQLPaymentPeriodicity) },
monthlyAmount: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLInt) },
autoRenew: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean) },
paymentMethodID: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) }
}
});
//# sourceMappingURL=subscription-public.js.map