Skip to content

Commit b63ac05

Browse files
Common proposals
Signed-off-by: Alexander Ivanov <[email protected]>
1 parent 07f2999 commit b63ac05

File tree

7 files changed

+67
-12
lines changed

7 files changed

+67
-12
lines changed

packages/firebase/functions/src/common/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
c// import { IBaseEntity } from '../util/types';
1+
// import { IBaseEntity } from '../util/types';
22
// import admin from 'firebase-admin';
33
// import Timestamp = admin.firestore.Timestamp;
44
//

packages/firebase/functions/src/subscriptions/index.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { commonApp, commonRouter } from '../util';
44
import { runtimeOptions } from '../util/constants';
55
import { CommonError } from '../util/errors';
66
import { responseExecutor } from '../util/responseExecutor';
7-
import { cancelSubscription, chargeSubscriptions, revokeMemberships } from './business';
7+
import { cancelSubscription, revokeMemberships } from './business';
88
import { CancellationReason } from './business/cancelSubscription';
99
import { subscriptionDb } from './database';
1010
import { env } from '../constants';
@@ -37,19 +37,13 @@ router.post('/cancel', async (req, res, next) => {
3737
});
3838
});
3939

40-
// if (env.environment !== 'production') {
40+
if (env.environment !== 'production') {
4141
router.get('/subscription/revoke', async (req, res) => {
4242
await revokeMemberships();
4343

4444
res.send('Done!');
4545
});
46-
47-
router.get('/subscription/charge', async (req, res) => {
48-
await chargeSubscriptions();
49-
50-
res.send('Done!');
51-
});
52-
// }
46+
}
5347

5448

5549
export const subscriptionsApp = functions

packages/graphql/src/generated/nexus-typegen.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ export interface NexusGenFieldTypes {
304304
firstName: string; // String!
305305
id: string; // ID!
306306
lastName: string; // String!
307+
proposals: NexusGenRootTypes['Proposal'][]; // [Proposal!]!
307308
updatedAt: NexusGenScalars['DateTime']; // DateTime!
308309
}
309310
Vote: { // field return type
@@ -387,6 +388,7 @@ export interface NexusGenFieldTypeNames {
387388
firstName: 'String'
388389
id: 'ID'
389390
lastName: 'String'
391+
proposals: 'Proposal'
390392
updatedAt: 'DateTime'
391393
}
392394
Vote: { // field return type name
@@ -409,6 +411,8 @@ export interface NexusGenArgTypes {
409411
take?: number | null; // Int
410412
}
411413
proposals: { // args
414+
skip?: number | null; // Int
415+
take: number | null; // Int
412416
where?: NexusGenInputs['ProposalWhereInput'] | null; // ProposalWhereInput
413417
}
414418
}
@@ -452,6 +456,11 @@ export interface NexusGenArgTypes {
452456
skip?: number | null; // Int
453457
take: number | null; // Int
454458
}
459+
proposals: { // args
460+
skip?: number | null; // Int
461+
take: number | null; // Int
462+
where?: NexusGenInputs['ProposalWhereInput'] | null; // ProposalWhereInput
463+
}
455464
}
456465
}
457466

packages/graphql/src/generated/schema.graphql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type Common {
3636

3737
"""The name of the common as provided"""
3838
name: String!
39-
proposals(where: ProposalWhereInput): [Proposal!]!
39+
proposals(skip: Int = 0, take: Int = 10, where: ProposalWhereInput): [Proposal!]!
4040

4141
"""The date, at which the item was last modified"""
4242
updatedAt: DateTime!
@@ -319,6 +319,7 @@ type User {
319319

320320
"""The last name of the user"""
321321
lastName: String!
322+
proposals(skip: Int = 0, take: Int = 10, where: ProposalWhereInput): [Proposal!]!
322323

323324
"""The date, at which the item was last modified"""
324325
updatedAt: DateTime!

packages/graphql/src/schema/Types/Commons/Extensions/CommonProposals.extension.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { extendType, arg } from 'nexus';
1+
import { extendType, arg, intArg } from 'nexus';
22
import { prisma } from '@common/core';
33

44
export const CommonProposalsExtension = extendType({
@@ -7,6 +7,14 @@ export const CommonProposalsExtension = extendType({
77
t.nonNull.list.nonNull.field('proposals', {
88
type: 'Proposal',
99
args: {
10+
take: intArg({
11+
default: 10
12+
}),
13+
14+
skip: intArg({
15+
default: 0
16+
}),
17+
1018
where: arg({
1119
type: 'ProposalWhereInput'
1220
})
@@ -19,6 +27,8 @@ export const CommonProposalsExtension = extendType({
1927
}
2028
})
2129
.proposals({
30+
take: args.take || undefined,
31+
skip: args.skip || undefined,
2232
where: (args.where as any) || undefined
2333
});
2434
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { extendType, intArg, arg } from 'nexus';
2+
import { prisma } from '@common/core';
3+
4+
export const UserProposalsExtension = extendType({
5+
type: 'User',
6+
definition(t) {
7+
t.nonNull.list.nonNull.field('proposals', {
8+
type: 'Proposal',
9+
complexity: 20,
10+
args: {
11+
take: intArg({
12+
default: 10
13+
}),
14+
15+
skip: intArg({
16+
default: 0
17+
}),
18+
19+
where: arg({
20+
type: 'ProposalWhereInput'
21+
})
22+
},
23+
resolve: (root, args) => {
24+
return prisma.user
25+
.findUnique({
26+
where: {
27+
id: root.id
28+
}
29+
})
30+
.proposals({
31+
take: args.take || undefined,
32+
skip: args.skip || undefined,
33+
where: (args.where as any) || undefined
34+
});
35+
}
36+
});
37+
}
38+
});

packages/graphql/src/schema/Types/Users/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { GetUserQuery } from './Queries/GetUser.query';
44
import { GenerateUserAuthTokenQuery } from './Queries/GenerateUserAuthToken.query';
55

66
import { CreateUserInput, CreateUserMutation } from './Mutations/CreateUser.mutation';
7+
78
import { UserEventsExtension } from './Extensions/UserEvents.extension';
9+
import { UserProposalsExtension } from './Extensions/UserProposals.extension';
810

911
export const UserTypes = [
1012
UserType,
@@ -15,6 +17,7 @@ export const UserTypes = [
1517
CreateUserMutation,
1618

1719
UserEventsExtension,
20+
UserProposalsExtension,
1821

1922
GenerateUserAuthTokenQuery
2023
];

0 commit comments

Comments
 (0)