@@ -25,8 +25,8 @@ import {
25
25
OrganizationListInput ,
26
26
SecuredOrganizationList ,
27
27
} from '../organization/dto' ;
28
- import { PartnerLoader } from '../partner' ;
29
- import { PartnerListInput , SecuredPartnerList } from '../partner/dto' ;
28
+ import { PartnerLoader , PartnerService } from '../partner' ;
29
+ import { Partner , PartnerListInput , SecuredPartnerList } from '../partner/dto' ;
30
30
import { TimeZoneService } from '../timezone' ;
31
31
import { SecuredTimeZone } from '../timezone/timezone.dto' ;
32
32
import {
@@ -70,6 +70,7 @@ class ModifyLocationArgs {
70
70
export class UserResolver {
71
71
constructor (
72
72
private readonly userService : UserService ,
73
+ private readonly partnerService : PartnerService ,
73
74
private readonly timeZoneService : TimeZoneService ,
74
75
private readonly identity : Identity ,
75
76
) { }
@@ -164,6 +165,14 @@ export class UserResolver {
164
165
return list ;
165
166
}
166
167
168
+ @ResolveField ( ( ) => Partner , { nullable : true } )
169
+ async primaryOrganization ( @Parent ( ) { id } : User ) : Promise < Partner | null > {
170
+ const primaryOrgId = await this . userService . getPrimaryOrganizationId ( id ) ;
171
+ return primaryOrgId
172
+ ? await this . partnerService . readOnePartnerByOrgId ( primaryOrgId )
173
+ : null ;
174
+ }
175
+
167
176
@ResolveField ( ( ) => SecuredPartnerList )
168
177
async partners (
169
178
@Parent ( ) { id } : User ,
@@ -263,8 +272,12 @@ export class UserResolver {
263
272
async assignOrganizationToUser (
264
273
@Args ( 'input' ) input : AssignOrganizationToUserInput ,
265
274
) : Promise < AssignOrganizationToUserOutput > {
266
- await this . userService . assignOrganizationToUser ( input . request ) ;
267
- return { success : true } ;
275
+ await this . userService . assignOrganizationToUser ( input . assignment ) ;
276
+ const partner = await this . partnerService . readOnePartnerByOrgId (
277
+ input . assignment . orgId ,
278
+ ) ;
279
+
280
+ return { partner } ;
268
281
}
269
282
270
283
@Mutation ( ( ) => RemoveOrganizationFromUserOutput , {
@@ -273,8 +286,11 @@ export class UserResolver {
273
286
async removeOrganizationFromUser (
274
287
@Args ( 'input' ) input : RemoveOrganizationFromUserInput ,
275
288
) : Promise < RemoveOrganizationFromUserOutput > {
276
- await this . userService . removeOrganizationFromUser ( input . request ) ;
277
- return { success : true } ;
289
+ await this . userService . removeOrganizationFromUser ( input . assignment ) ;
290
+ const partner = await this . partnerService . readOnePartnerByOrgId (
291
+ input . assignment . orgId ,
292
+ ) ;
293
+ return { partner } ;
278
294
}
279
295
280
296
@Mutation ( ( ) => User , {
0 commit comments