-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcustom.input.ts
44 lines (36 loc) · 1.06 KB
/
custom.input.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Field, InputType, Int } from '@nestjs/graphql';
import { IsNotEmpty, IsOptional } from 'class-validator';
import GraphQLJSON from 'graphql-type-json';
import { FindOptionsOrder } from 'typeorm';
import { IWhere } from './utils/types';
@InputType()
export class IPagination {
@Field(() => Int, { description: 'Started from 0' })
@IsNotEmpty()
page: number;
@Field(() => Int, { description: 'Size of page' })
@IsNotEmpty()
size: number;
}
@InputType()
export class GetOneInput<T> {
@Field(() => GraphQLJSON)
@IsNotEmpty()
where: IWhere<T>;
}
@InputType()
export class GetManyInput<T> {
@Field(() => GraphQLJSON, { nullable: true })
@IsOptional()
where?: IWhere<T>;
@Field(() => IPagination, { nullable: true })
@IsOptional()
pagination?: IPagination;
@Field(() => GraphQLJSON, {
nullable: true,
description:
'{key: "ASC" or "DESC" or "asc" or "desc" or 1 or -1} or {key: {direction: "ASC" or "DESC" or "asc" or "desc", nulls: "first" or "last" or "FIRST" or "LAST"}}}',
})
@IsOptional()
order?: FindOptionsOrder<T>;
}