@things-factory/work-shift 5.0.7 → 6.0.0-alpha.0

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.
@@ -1,8 +1,7 @@
1
1
  import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
2
- import { getRepository } from 'typeorm'
3
2
 
4
3
  import { User } from '@things-factory/auth-base'
5
- import { Domain, getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'
4
+ import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
6
5
 
7
6
  import { getWorkDateAndShift } from '../../controllers/index'
8
7
  import { WorkShift } from './work-shift'
@@ -11,7 +10,10 @@ import { WorkDateWorkShiftPair, WorkShiftList } from './work-shift-type'
11
10
  @Resolver(Domain)
12
11
  export class DomainWorkShiftQuery {
13
12
  @Query(returns => WorkDateWorkShiftPair, { description: 'To fetch a work date and work shift for given datetime' })
14
- async getWorkDateAndShift(@Arg('dateTime') dateTime: Date, @Ctx() context: any): Promise<WorkDateWorkShiftPair> {
13
+ async getWorkDateAndShift(
14
+ @Arg('dateTime') dateTime: Date,
15
+ @Ctx() context: ResolverContext
16
+ ): Promise<WorkDateWorkShiftPair> {
15
17
  const { domain } = context.state
16
18
 
17
19
  return await getWorkDateAndShift(domain, dateTime)
@@ -34,7 +36,7 @@ export class DomainWorkShiftQuery {
34
36
  @Resolver(WorkShift)
35
37
  export class WorkShiftQuery {
36
38
  @Query(returns => WorkShiftList, { description: 'To fetch multiple WorkShifts' })
37
- async workShifts(@Args() params: ListParam, @Ctx() context: any): Promise<WorkShiftList> {
39
+ async workShifts(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<WorkShiftList> {
38
40
  const { domain } = context.state
39
41
 
40
42
  const queryBuilder = getQueryBuilderFromListParams({
@@ -50,16 +52,16 @@ export class WorkShiftQuery {
50
52
 
51
53
  @FieldResolver(type => Domain)
52
54
  async domain(@Root() workShift: WorkShift): Promise<Domain> {
53
- return await getRepository(Domain).findOne(workShift.domainId)
55
+ return await getRepository(Domain).findOneBy({ id: workShift.domainId })
54
56
  }
55
57
 
56
58
  @FieldResolver(type => User)
57
59
  async updater(@Root() workShift: WorkShift): Promise<User> {
58
- return await getRepository(User).findOne(workShift.updaterId)
60
+ return await getRepository(User).findOneBy({ id: workShift.updaterId })
59
61
  }
60
62
 
61
63
  @FieldResolver(type => User)
62
64
  async creator(@Root() workShift: WorkShift): Promise<User> {
63
- return await getRepository(User).findOne(workShift.creatorId)
65
+ return await getRepository(User).findOneBy({ id: workShift.creatorId })
64
66
  }
65
67
  }