@quesmed/types-rn 2.6.10 → 2.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/resolvers/apollo.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DefaultContext, FetchResult } from '@apollo/client';
|
|
2
2
|
export type ApolloUpdateResultRestricted<T> = Omit<FetchResult<T>, 'context'>;
|
|
3
|
-
export interface ApolloUpdateOptions {
|
|
3
|
+
export interface ApolloUpdateOptions<T = Record<string, any>> {
|
|
4
4
|
context?: DefaultContext;
|
|
5
|
-
variables?:
|
|
5
|
+
variables?: T;
|
|
6
6
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { ApolloCache } from '@apollo/client';
|
|
2
|
+
import { ISubscription } from '../../../models';
|
|
3
|
+
import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../../apollo';
|
|
1
4
|
import { RestrictedData, graphqlNormalize } from '../../types';
|
|
2
5
|
export interface ICancelSubscriptionVar {
|
|
3
6
|
subscriptionId: number;
|
|
4
7
|
}
|
|
5
|
-
export type ICancelSubscriptionData = RestrictedData<graphqlNormalize &
|
|
8
|
+
export type ICancelSubscriptionData = RestrictedData<graphqlNormalize & ISubscription, 'cancelSubscription'>;
|
|
6
9
|
export declare const CANCEL_SUBSCRIPTION: import("@apollo/client").DocumentNode;
|
|
10
|
+
export declare const updateSubscriptionOnCancelOrRenew: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<ICancelSubscriptionData>, options: ApolloUpdateOptions<ICancelSubscriptionVar>) => void;
|
|
@@ -1,11 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CANCEL_SUBSCRIPTION = void 0;
|
|
3
|
+
exports.updateSubscriptionOnCancelOrRenew = exports.CANCEL_SUBSCRIPTION = void 0;
|
|
4
4
|
const client_1 = require("@apollo/client");
|
|
5
|
+
const restricted_1 = require("../../query/restricted");
|
|
5
6
|
exports.CANCEL_SUBSCRIPTION = (0, client_1.gql) `
|
|
6
7
|
mutation Mutation($subscriptionId: Int!) {
|
|
7
8
|
restricted {
|
|
8
|
-
cancelSubscription(subscriptionId: $subscriptionId)
|
|
9
|
+
cancelSubscription(subscriptionId: $subscriptionId) {
|
|
10
|
+
id
|
|
11
|
+
endedAt
|
|
12
|
+
periodEndAt
|
|
13
|
+
stripeSubscriptionId
|
|
14
|
+
userId
|
|
15
|
+
productId
|
|
16
|
+
}
|
|
9
17
|
}
|
|
10
18
|
}
|
|
11
19
|
`;
|
|
20
|
+
const updateSubscriptionOnCancelOrRenew = (cache, result, options) => {
|
|
21
|
+
const { cancelSubscription } = result?.data?.restricted || {};
|
|
22
|
+
const { variables } = options || {};
|
|
23
|
+
if (!variables || !cancelSubscription) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const prevData = cache.readQuery({
|
|
27
|
+
query: restricted_1.USER,
|
|
28
|
+
});
|
|
29
|
+
if (!prevData) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const { subscriptionId } = variables;
|
|
33
|
+
const { subscriptions } = prevData.restricted.user;
|
|
34
|
+
prevData.restricted.user.subscriptions = subscriptions.map((s) => Number(s.id) === Number(subscriptionId)
|
|
35
|
+
? { ...s, ...cancelSubscription }
|
|
36
|
+
: s);
|
|
37
|
+
cache.writeQuery({ query: restricted_1.USER, data: { ...prevData } });
|
|
38
|
+
};
|
|
39
|
+
exports.updateSubscriptionOnCancelOrRenew = updateSubscriptionOnCancelOrRenew;
|
|
@@ -1019,6 +1019,7 @@ exports.MARKSHEETS = (0, client_1.gql) `
|
|
|
1019
1019
|
marksheets(filter: $filter) {
|
|
1020
1020
|
results {
|
|
1021
1021
|
id
|
|
1022
|
+
source
|
|
1022
1023
|
endedAt
|
|
1023
1024
|
topicNames
|
|
1024
1025
|
correct
|
|
@@ -1057,6 +1058,7 @@ exports.MARKSHEETS_WINDOW = (0, client_1.gql) `
|
|
|
1057
1058
|
date
|
|
1058
1059
|
result {
|
|
1059
1060
|
id
|
|
1061
|
+
source
|
|
1060
1062
|
endedAt
|
|
1061
1063
|
topicNames
|
|
1062
1064
|
correct
|