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 getInvoices from './queries/get-invoices.ee';
|
||||||
import getAutomatischInfo from './queries/get-automatisch-info';
|
import getAutomatischInfo from './queries/get-automatisch-info';
|
||||||
import getTrialStatus from './queries/get-trial-status.ee';
|
import getTrialStatus from './queries/get-trial-status.ee';
|
||||||
|
import getSubscriptionStatus from './queries/get-subscription-status.ee';
|
||||||
import healthcheck from './queries/healthcheck';
|
import healthcheck from './queries/healthcheck';
|
||||||
|
|
||||||
const queryResolvers = {
|
const queryResolvers = {
|
||||||
@@ -41,6 +42,7 @@ const queryResolvers = {
|
|||||||
getInvoices,
|
getInvoices,
|
||||||
getAutomatischInfo,
|
getAutomatischInfo,
|
||||||
getTrialStatus,
|
getTrialStatus,
|
||||||
|
getSubscriptionStatus,
|
||||||
healthcheck,
|
healthcheck,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -41,6 +41,7 @@ type Query {
|
|||||||
getInvoices: [Invoice]
|
getInvoices: [Invoice]
|
||||||
getAutomatischInfo: GetAutomatischInfo
|
getAutomatischInfo: GetAutomatischInfo
|
||||||
getTrialStatus: GetTrialStatus
|
getTrialStatus: GetTrialStatus
|
||||||
|
getSubscriptionStatus: GetSubscriptionStatus
|
||||||
healthcheck: AppHealth
|
healthcheck: AppHealth
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,6 +488,10 @@ type GetTrialStatus {
|
|||||||
expireAt: String
|
expireAt: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetSubscriptionStatus {
|
||||||
|
cancellationEffectiveDate: String
|
||||||
|
}
|
||||||
|
|
||||||
type GetBillingAndUsage {
|
type GetBillingAndUsage {
|
||||||
subscription: Subscription
|
subscription: Subscription
|
||||||
usage: Usage
|
usage: Usage
|
||||||
|
@@ -11,7 +11,7 @@ export const worker = new Worker(
|
|||||||
await Subscription.query()
|
await Subscription.query()
|
||||||
.delete()
|
.delete()
|
||||||
.where({
|
.where({
|
||||||
status: 'cancelled',
|
status: 'deleted',
|
||||||
})
|
})
|
||||||
.andWhere(
|
.andWhere(
|
||||||
'cancellation_effective_date',
|
'cancellation_effective_date',
|
||||||
|
Reference in New Issue
Block a user