@@ -4,136 +4,88 @@ import IParticipantService from "../../services/interface/participantInterface";
44
55const participantService : IParticipantService = new ParticipantService ( ) ;
66const participantResolvers = {
7- Query : {
8- getPastParticipants : async ( ) : Promise < Participant [ ] > => {
9- return participantService . getPastParticipants ( ) ;
7+ Query : {
8+ getPastParticipants : async ( ) : Promise < Participant [ ] > => {
9+ return participantService . getPastParticipants ( ) ;
10+ } ,
11+ getCurrentParticipants : async ( ) : Promise < Participant [ ] > => {
12+ return participantService . getCurrentParticipants ( ) ;
13+ } ,
14+ getParticipantById : async (
15+ _parent : undefined ,
16+ { participantId } : { participantId : string } ,
17+ ) : Promise < Participant | null > => {
18+ return participantService . getParticipantById ( participantId ) ;
19+ } ,
20+ getParticipantByRoom : async (
21+ _parent : undefined ,
22+ { roomNumber } : { roomNumber : number } ,
23+ ) : Promise < Participant | null > => {
24+ return participantService . getParticipantByRoom ( roomNumber ) ;
25+ }
1026 } ,
11- getCurrentParticipants : async ( ) : Promise < Participant [ ] > => {
12- return participantService . getCurrentParticipants ( ) ;
27+ Mutation : {
28+ createParticipant : async (
29+ _parent : undefined ,
30+ {
31+ participantId,
32+ roomNumber,
33+ arrival,
34+ password,
35+ } : {
36+ participantId : string ;
37+ roomNumber : number ;
38+ arrival : string ;
39+ password : string ;
40+ } ,
41+ ) : Promise < boolean > => {
42+ return participantService . createParticipant (
43+ participantId ,
44+ roomNumber ,
45+ arrival ,
46+ password ,
47+ ) ;
48+ } ,
49+ updateParticipantById : async (
50+ _parent : undefined ,
51+ {
52+ participantId,
53+ roomNumber,
54+ arrival,
55+ departure,
56+ password,
57+ } : {
58+ participantId : string ;
59+ roomNumber ?: number ;
60+ arrival ?: string ;
61+ departure ?: string ;
62+ password ?: string ;
63+ } ,
64+ ) : Promise < boolean > => {
65+ return participantService . updateParticipantById (
66+ participantId ,
67+ roomNumber ,
68+ arrival ,
69+ departure ,
70+ password ,
71+ ) ;
72+ } ,
73+ editMarillacBucks : async (
74+ _parent : undefined ,
75+ {
76+ participantId,
77+ credit
78+ } : {
79+ participantId : string ;
80+ credit : number ;
81+ } ,
82+ ) : Promise < boolean > => {
83+ return participantService . updateParticipantCredit (
84+ participantId ,
85+ credit
86+ ) ;
87+ } ,
1388 } ,
14- getParticipantById : async (
15- _parent : undefined ,
16- { participantId } : { participantId : string } ,
17- ) : Promise < Participant | null > => {
18- return participantService . getParticipantById ( participantId ) ;
19- } ,
20- } ,
21- Mutation : {
22- createParticipant : async (
23- _parent : undefined ,
24- {
25- participantId,
26- roomNumber,
27- arrival,
28- password,
29- } : {
30- participantId : string ;
31- roomNumber : number ;
32- arrival : string ;
33- password : string ;
34- } ,
35- ) : Promise < boolean > => {
36- return participantService . createParticipant (
37- participantId ,
38- roomNumber ,
39- arrival ,
40- password ,
41- ) ;
42- } ,
43- updateParticipantById : async (
44- _parent : undefined ,
45- {
46- participantId,
47- roomNumber,
48- arrival,
49- departure,
50- password,
51- } : {
52- participantId : string ;
53- roomNumber ?: number ;
54- arrival ?: string ;
55- departure ?: string ;
56- password ?: string ;
57- } ,
58- ) : Promise < boolean > => {
59- return participantService . updateParticipantById (
60- participantId ,
61- roomNumber ,
62- arrival ,
63- departure ,
64- password ,
65- ) ;
66- } ,
67- } ,
6889} ;
6990
7091export default participantResolvers ;
71-
72- // import IResidentService, {
73- // ResidentDTO,
74- // CreateResidentDTO,
75- // UpdateResidentDTO,
76- // RedeemCreditsResponse,
77- // } from "../../services/interface/residentService";
78-
79- // const residentResolvers = {
80- // Query: {
81- // getResidentsByIds: async (
82- // _parent: undefined,
83- // { userIds }: { userIds: string[] },
84- // ): Promise<Array<ResidentDTO>> => {
85- // return residentService.getResidentsByIds(userIds.map(Number));
86- // },
87- // getAllResidents: async (): Promise<Array<ResidentDTO>> => {
88- // return residentService.getAllResidents();
89- // },
90- // getActiveResidents: async (): Promise<ResidentDTO[]> => {
91- // const activeResidents = await residentService.getActiveResidents();
92- // return activeResidents;
93- // },
94- // },
95- // Mutation: {
96- // addResident: async (
97- // _parent: undefined,
98- // {
99- // resident,
100- // }: {
101- // resident: CreateResidentDTO;
102- // },
103- // ): Promise<ResidentDTO> => {
104- // const newResident = await residentService.addResident(resident);
105- // return newResident;
106- // },
107- // updateResident: async (
108- // _parent: undefined,
109- // {
110- // userId,
111- // resident,
112- // }: {
113- // userId: string;
114- // resident: UpdateResidentDTO;
115- // },
116- // ): Promise<ResidentDTO> => {
117- // const newResident = await residentService.updateResident(
118- // parseInt(userId, 10),
119- // resident,
120- // );
121- // return newResident;
122- // },
123- // deleteResident: async (
124- // _parent: undefined,
125- // { userId }: { userId: string },
126- // ): Promise<ResidentDTO> => {
127- // const deletedResident = await residentService.deleteResident(
128- // parseInt(userId, 10),
129- // );
130- // return deletedResident;
131- // },
132- // redeemCredits: async (
133- // _parent: undefined,
134- // { userId, credits }: { userId: string; credits: number },
135- // ): Promise<RedeemCreditsResponse> => {
136- // return residentService.redeemCredits(parseInt(userId, 10), credits);
137- // },
138- // },
139- // };
0 commit comments