feat: Add getSubscriptionStatus graphQL query
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import appConfig from '../../config/app';
|
||||
import Context from '../../types/express/context';
|
||||
|
||||
const getSubscriptionStatus = async (
|
||||
_parent: unknown,
|
||||
_params: unknown,
|
||||
context: Context
|
||||
) => {
|
||||
if (!appConfig.isCloud) return;
|
||||
|
||||
const currentSubscription = await context.currentUser.$relatedQuery(
|
||||
'currentSubscription'
|
||||
);
|
||||
|
||||
if (!currentSubscription?.cancellationEffectiveDate) return;
|
||||
|
||||
return {
|
||||
cancellationEffectiveDate: currentSubscription.cancellationEffectiveDate,
|
||||
};
|
||||
};
|
||||
|
||||
export default getSubscriptionStatus;
|
@@ -18,6 +18,7 @@ import getBillingAndUsage from './queries/get-billing-and-usage.ee';
|
||||
import getInvoices from './queries/get-invoices.ee';
|
||||
import getAutomatischInfo from './queries/get-automatisch-info';
|
||||
import getTrialStatus from './queries/get-trial-status.ee';
|
||||
import getSubscriptionStatus from './queries/get-subscription-status.ee';
|
||||
import healthcheck from './queries/healthcheck';
|
||||
|
||||
const queryResolvers = {
|
||||
@@ -41,6 +42,7 @@ const queryResolvers = {
|
||||
getInvoices,
|
||||
getAutomatischInfo,
|
||||
getTrialStatus,
|
||||
getSubscriptionStatus,
|
||||
healthcheck,
|
||||
};
|
||||
|
||||
|
@@ -41,6 +41,7 @@ type Query {
|
||||
getInvoices: [Invoice]
|
||||
getAutomatischInfo: GetAutomatischInfo
|
||||
getTrialStatus: GetTrialStatus
|
||||
getSubscriptionStatus: GetSubscriptionStatus
|
||||
healthcheck: AppHealth
|
||||
}
|
||||
|
||||
@@ -487,6 +488,10 @@ type GetTrialStatus {
|
||||
expireAt: String
|
||||
}
|
||||
|
||||
type GetSubscriptionStatus {
|
||||
cancellationEffectiveDate: String
|
||||
}
|
||||
|
||||
type GetBillingAndUsage {
|
||||
subscription: Subscription
|
||||
usage: Usage
|
||||
|
@@ -11,7 +11,7 @@ export const worker = new Worker(
|
||||
await Subscription.query()
|
||||
.delete()
|
||||
.where({
|
||||
status: 'cancelled',
|
||||
status: 'deleted',
|
||||
})
|
||||
.andWhere(
|
||||
'cancellation_effective_date',
|
||||
|
Reference in New Issue
Block a user