@@ -9,7 +9,14 @@ import {
9
9
UnPagedRelation
10
10
} from '@ptc-org/nestjs-query-graphql'
11
11
12
- import { CursorConnection , FilterableCursorConnection , FilterableOffsetConnection , getRelations } from '../../src/decorators'
12
+ import {
13
+ CursorConnection ,
14
+ FilterableCursorConnection ,
15
+ FilterableOffsetConnection ,
16
+ getRelations ,
17
+ RelationOneDecoratorOpts
18
+ } from '../../src/decorators'
19
+ import { RelationManyDecoratorOpts } from 'packages/query-graphql/src/decorators/relation.decorator'
13
20
14
21
@ObjectType ( )
15
22
class TestRelation { }
@@ -26,6 +33,23 @@ describe('@Relation', () => {
26
33
const relations = getRelations ( TestDTO )
27
34
expect ( relations ) . toEqual ( { one : { test : { DTO : TestRelation , allowFiltering : false , ...relationOpts } } } )
28
35
} )
36
+
37
+ it ( 'should add the deprecationReason to the options' , ( ) => {
38
+ // Arrange
39
+ const relationFn = ( ) => TestRelation
40
+ const relationOpts : Partial < RelationOneDecoratorOpts < TestRelation > > = {
41
+ deprecationReason : 'Deprecated for no apparent reason.'
42
+ }
43
+ @ObjectType ( )
44
+ @Relation ( 'test' , relationFn , relationOpts )
45
+ class TestDTO { }
46
+
47
+ // Act
48
+ const relations = getRelations ( TestDTO )
49
+
50
+ // Assert
51
+ expect ( relations ) . toEqual ( { one : { test : { DTO : TestRelation , allowFiltering : false , ...relationOpts } } } )
52
+ } )
29
53
} )
30
54
31
55
describe ( '@FilterableRelation' , ( ) => {
@@ -40,6 +64,23 @@ describe('@FilterableRelation', () => {
40
64
const relations = getRelations ( TestDTO )
41
65
expect ( relations ) . toEqual ( { one : { test : { DTO : TestRelation , ...relationOpts , allowFiltering : true } } } )
42
66
} )
67
+
68
+ it ( 'should add the deprecationReason to the options' , ( ) => {
69
+ // Arrange
70
+ const relationFn = ( ) => TestRelation
71
+ const relationOpts : Partial < RelationOneDecoratorOpts < TestRelation > > = {
72
+ deprecationReason : 'Deprecated for no apparent reason.'
73
+ }
74
+ @ObjectType ( )
75
+ @FilterableRelation ( 'test' , relationFn , relationOpts )
76
+ class TestDTO { }
77
+
78
+ // Act
79
+ const relations = getRelations ( TestDTO )
80
+
81
+ // Assert
82
+ expect ( relations ) . toEqual ( { one : { test : { DTO : TestRelation , ...relationOpts , allowFiltering : true } } } )
83
+ } )
43
84
} )
44
85
45
86
describe ( '@UnPagedRelation' , ( ) => {
@@ -58,6 +99,27 @@ describe('@UnPagedRelation', () => {
58
99
}
59
100
} )
60
101
} )
102
+
103
+ it ( 'should add the deprecationReason to the options' , ( ) => {
104
+ // Arrange
105
+ const relationFn = ( ) => TestRelation
106
+ const relationOpts : Partial < RelationManyDecoratorOpts < TestRelation > > = {
107
+ deprecationReason : 'Deprecated for no apparent reason.'
108
+ }
109
+ @ObjectType ( )
110
+ @UnPagedRelation ( 'tests' , relationFn , relationOpts )
111
+ class TestDTO { }
112
+
113
+ // Act
114
+ const relations = getRelations ( TestDTO )
115
+
116
+ // Assert
117
+ expect ( relations ) . toEqual ( {
118
+ many : {
119
+ tests : { DTO : TestRelation , ...relationOpts , allowFiltering : false , pagingStrategy : PagingStrategies . NONE }
120
+ }
121
+ } )
122
+ } )
61
123
} )
62
124
63
125
describe ( '@FilterableUnPagedRelation' , ( ) => {
@@ -76,6 +138,27 @@ describe('@FilterableUnPagedRelation', () => {
76
138
}
77
139
} )
78
140
} )
141
+
142
+ it ( 'should add the deprecationReason to the options' , ( ) => {
143
+ // Arrange
144
+ const relationFn = ( ) => TestRelation
145
+ const relationOpts : Partial < RelationManyDecoratorOpts < TestRelation > > = {
146
+ deprecationReason : 'Deprecated for no apparent reason.'
147
+ }
148
+ @ObjectType ( )
149
+ @FilterableUnPagedRelation ( 'test' , relationFn , relationOpts )
150
+ class TestDTO { }
151
+
152
+ // Act
153
+ const relations = getRelations ( TestDTO )
154
+
155
+ // Assert
156
+ expect ( relations ) . toEqual ( {
157
+ many : {
158
+ test : { DTO : TestRelation , pagingStrategy : PagingStrategies . NONE , ...relationOpts , allowFiltering : true }
159
+ }
160
+ } )
161
+ } )
79
162
} )
80
163
81
164
describe ( '@OffsetConnection' , ( ) => {
@@ -94,6 +177,27 @@ describe('@OffsetConnection', () => {
94
177
}
95
178
} )
96
179
} )
180
+
181
+ it ( 'should add the deprecationReason to the options' , ( ) => {
182
+ // Arrange
183
+ const relationFn = ( ) => TestRelation
184
+ const relationOpts : Partial < RelationManyDecoratorOpts < TestRelation > > = {
185
+ deprecationReason : 'Deprecated for no apparent reason.'
186
+ }
187
+ @ObjectType ( )
188
+ @OffsetConnection ( 'test' , relationFn , relationOpts )
189
+ class TestDTO { }
190
+
191
+ // Act
192
+ const relations = getRelations ( TestDTO )
193
+
194
+ // Assert
195
+ expect ( relations ) . toEqual ( {
196
+ many : {
197
+ test : { DTO : TestRelation , ...relationOpts , allowFiltering : false , pagingStrategy : PagingStrategies . OFFSET }
198
+ }
199
+ } )
200
+ } )
97
201
} )
98
202
99
203
describe ( '@FilterableOffsetConnection' , ( ) => {
@@ -112,6 +216,27 @@ describe('@FilterableOffsetConnection', () => {
112
216
}
113
217
} )
114
218
} )
219
+
220
+ it ( 'should add the deprecationReason to the options' , ( ) => {
221
+ // Arrange
222
+ const relationFn = ( ) => TestRelation
223
+ const relationOpts : Partial < RelationManyDecoratorOpts < TestRelation > > = {
224
+ deprecationReason : 'Deprecated for no apparent reason.'
225
+ }
226
+ @ObjectType ( )
227
+ @FilterableOffsetConnection ( 'test' , relationFn , relationOpts )
228
+ class TestDTO { }
229
+
230
+ // Act
231
+ const relations = getRelations ( TestDTO )
232
+
233
+ // Assert
234
+ expect ( relations ) . toEqual ( {
235
+ many : {
236
+ test : { DTO : TestRelation , ...relationOpts , pagingStrategy : PagingStrategies . OFFSET , allowFiltering : true }
237
+ }
238
+ } )
239
+ } )
115
240
} )
116
241
117
242
describe ( '@CursorConnection' , ( ) => {
@@ -130,6 +255,27 @@ describe('@CursorConnection', () => {
130
255
}
131
256
} )
132
257
} )
258
+
259
+ it ( 'should add the deprecationReason to the options' , ( ) => {
260
+ // Arrange
261
+ const relationFn = ( ) => TestRelation
262
+ const relationOpts : Partial < RelationManyDecoratorOpts < TestRelation > > = {
263
+ deprecationReason : 'Deprecated for no apparent reason.'
264
+ }
265
+ @ObjectType ( )
266
+ @CursorConnection ( 'test' , relationFn , relationOpts )
267
+ class TestDTO { }
268
+
269
+ // Act
270
+ const relations = getRelations ( TestDTO )
271
+
272
+ // Assert
273
+ expect ( relations ) . toEqual ( {
274
+ many : {
275
+ test : { DTO : TestRelation , ...relationOpts , allowFiltering : false , pagingStrategy : PagingStrategies . CURSOR }
276
+ }
277
+ } )
278
+ } )
133
279
} )
134
280
135
281
describe ( '@FilterableCursorConnection' , ( ) => {
@@ -148,6 +294,27 @@ describe('@FilterableCursorConnection', () => {
148
294
}
149
295
} )
150
296
} )
297
+
298
+ it ( 'should add the deprecationReason to the options' , ( ) => {
299
+ // Arrange
300
+ const relationFn = ( ) => TestRelation
301
+ const relationOpts : Partial < RelationManyDecoratorOpts < TestRelation > > = {
302
+ deprecationReason : 'Deprecated for no apparent reason.'
303
+ }
304
+ @ObjectType ( )
305
+ @FilterableCursorConnection ( 'test' , relationFn , relationOpts )
306
+ class TestDTO { }
307
+
308
+ // Act
309
+ const relations = getRelations ( TestDTO )
310
+
311
+ // Assert
312
+ expect ( relations ) . toEqual ( {
313
+ many : {
314
+ test : { DTO : TestRelation , ...relationOpts , pagingStrategy : PagingStrategies . CURSOR , allowFiltering : true }
315
+ }
316
+ } )
317
+ } )
151
318
} )
152
319
153
320
describe ( 'getRelations' , ( ) => {
0 commit comments