@@ -9,7 +9,14 @@ import {
99 UnPagedRelation
1010} from '@ptc-org/nestjs-query-graphql'
1111
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'
1320
1421@ObjectType ( )
1522class TestRelation { }
@@ -26,6 +33,23 @@ describe('@Relation', () => {
2633 const relations = getRelations ( TestDTO )
2734 expect ( relations ) . toEqual ( { one : { test : { DTO : TestRelation , allowFiltering : false , ...relationOpts } } } )
2835 } )
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+ } )
2953} )
3054
3155describe ( '@FilterableRelation' , ( ) => {
@@ -40,6 +64,23 @@ describe('@FilterableRelation', () => {
4064 const relations = getRelations ( TestDTO )
4165 expect ( relations ) . toEqual ( { one : { test : { DTO : TestRelation , ...relationOpts , allowFiltering : true } } } )
4266 } )
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+ } )
4384} )
4485
4586describe ( '@UnPagedRelation' , ( ) => {
@@ -58,6 +99,27 @@ describe('@UnPagedRelation', () => {
5899 }
59100 } )
60101 } )
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+ } )
61123} )
62124
63125describe ( '@FilterableUnPagedRelation' , ( ) => {
@@ -76,6 +138,27 @@ describe('@FilterableUnPagedRelation', () => {
76138 }
77139 } )
78140 } )
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+ } )
79162} )
80163
81164describe ( '@OffsetConnection' , ( ) => {
@@ -94,6 +177,27 @@ describe('@OffsetConnection', () => {
94177 }
95178 } )
96179 } )
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+ } )
97201} )
98202
99203describe ( '@FilterableOffsetConnection' , ( ) => {
@@ -112,6 +216,27 @@ describe('@FilterableOffsetConnection', () => {
112216 }
113217 } )
114218 } )
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+ } )
115240} )
116241
117242describe ( '@CursorConnection' , ( ) => {
@@ -130,6 +255,27 @@ describe('@CursorConnection', () => {
130255 }
131256 } )
132257 } )
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+ } )
133279} )
134280
135281describe ( '@FilterableCursorConnection' , ( ) => {
@@ -148,6 +294,27 @@ describe('@FilterableCursorConnection', () => {
148294 }
149295 } )
150296 } )
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+ } )
151318} )
152319
153320describe ( 'getRelations' , ( ) => {
0 commit comments