feat: Add getSubscriptionStatus graphQL query

This commit is contained in:
Faruk AYDIN
2023-04-12 21:29:36 +02:00
parent d1344457dd
commit d2163f180e
4 changed files with 30 additions and 1 deletions

View File

@@ -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;

View File

@@ -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,
};

View File

@@ -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

View File

@@ -11,7 +11,7 @@ export const worker = new Worker(
await Subscription.query()
.delete()
.where({
status: 'cancelled',
status: 'deleted',
})
.andWhere(
'cancellation_effective_date',