@@ -16,7 +16,7 @@ describe('_disTypes Test With and Without test_disTypes Options set', () => {
1616
1717 afterEach ( ( ) => Event . remove ( { } ) ) ;
1818
19- describe ( 'No test_disTypes, Include types Manually in Query ' , ( ) => {
19+ describe ( 'opts test_disTypes FALSE ' , ( ) => {
2020 let EventTC ;
2121 let ClickedLinkEventTC ;
2222
@@ -31,67 +31,6 @@ describe('_disTypes Test With and Without test_disTypes Options set', () => {
3131 expect ( ClickedLinkEventTC . getFieldNames ( ) ) . toEqual ( [ '_id' , 'kind' , 'refId' , 'url' ] ) ;
3232 } ) ;
3333
34- it ( 'manually override resolver output type for findMany' , async ( ) => {
35- // let's check graphql response
36-
37- await Event . create ( { refId : 'aaa' } ) ;
38- await Event . create ( { refId : 'bbb' } ) ;
39- await ClickedLinkEvent . create ( { refId : 'ccc' , url : 'url1' } ) ;
40- await ClickedLinkEvent . create ( { refId : 'ddd' , url : 'url2' } ) ;
41-
42- schemaComposer . rootQuery ( ) . addFields ( {
43- eventFindMany : EventTC . getResolver ( 'findMany' ) ,
44- ClickedLinkEvent : ClickedLinkEventTC . getResolver ( 'findMany' ) ,
45- GenericEvent : EventTC . getResolver ( 'findOne' ) . setType ( EventTC ) ,
46- } ) ;
47-
48- const schema = schemaComposer . buildSchema ( ) ;
49-
50- const res = await graphql . graphql (
51- schema ,
52- `{
53- eventFindMany {
54- __typename
55- ... on GenericEvent {
56- refId
57- }
58- ... on ClickedLinkEvent {
59- kind
60- refId
61- url
62- }
63- }
64- }`
65- ) ;
66-
67- expect ( res ) . toEqual ( {
68- data : {
69- eventFindMany : [
70- { __typename : 'GenericEvent' , refId : 'aaa' } ,
71- { __typename : 'GenericEvent' , refId : 'bbb' } ,
72- { __typename : 'ClickedLinkEvent' , kind : 'ClickedLinkEvent' , refId : 'ccc' , url : 'url1' } ,
73- { __typename : 'ClickedLinkEvent' , kind : 'ClickedLinkEvent' , refId : 'ddd' , url : 'url2' } ,
74- ] ,
75- } ,
76- } ) ;
77- } ) ;
78- } ) ;
79-
80- describe ( 'opts test_disTypes TRUE' , ( ) => {
81- let EventTC ;
82- let ClickedLinkEventTC ;
83-
84- beforeAll ( ( ) => {
85- schemaComposer . clear ( ) ;
86- EventTC = composeWithMongooseDiscriminators ( Event , { test_disTypes : true } ) ;
87- ClickedLinkEventTC = EventTC . discriminator ( ClickedLinkEvent ) ;
88- } ) ;
89-
90- it ( 'creating Types from models' , ( ) => {
91- expect ( EventTC . getFieldNames ( ) ) . toEqual ( [ '_id' , 'kind' , 'refId' ] ) ;
92- expect ( ClickedLinkEventTC . getFieldNames ( ) ) . toEqual ( [ '_id' , 'kind' , 'refId' , 'url' ] ) ;
93- } ) ;
94-
9534 it ( 'manually override resolver output type for findMany' , async ( ) => {
9635 // let's check graphql response
9736
@@ -111,7 +50,7 @@ describe('_disTypes Test With and Without test_disTypes Options set', () => {
11150 `{
11251 eventFindMany {
11352 __typename
114- ... on GenericEvent {
53+ ... on Event {
11554 refId
11655 }
11756 ... on ClickedLinkEvent {
@@ -126,64 +65,13 @@ describe('_disTypes Test With and Without test_disTypes Options set', () => {
12665 expect ( res ) . toEqual ( {
12766 data : {
12867 eventFindMany : [
129- { __typename : 'GenericEvent ' , refId : 'aaa' } ,
130- { __typename : 'GenericEvent ' , refId : 'bbb' } ,
68+ { __typename : 'Event ' , refId : 'aaa' } ,
69+ { __typename : 'Event ' , refId : 'bbb' } ,
13170 { __typename : 'ClickedLinkEvent' , kind : 'ClickedLinkEvent' , refId : 'ccc' , url : 'url1' } ,
13271 { __typename : 'ClickedLinkEvent' , kind : 'ClickedLinkEvent' , refId : 'ddd' , url : 'url2' } ,
13372 ] ,
13473 } ,
13574 } ) ;
13675 } ) ;
13776 } ) ;
138-
139- describe ( 'opts test_disTypes FALSE' , ( ) => {
140- let EventTC ;
141- let ClickedLinkEventTC ;
142-
143- beforeAll ( ( ) => {
144- schemaComposer . clear ( ) ;
145- EventTC = composeWithMongooseDiscriminators ( Event , { test_disTypes : false } ) ;
146- ClickedLinkEventTC = EventTC . discriminator ( ClickedLinkEvent ) ;
147- } ) ;
148-
149- it ( 'creating Types from models' , ( ) => {
150- expect ( EventTC . getFieldNames ( ) ) . toEqual ( [ '_id' , 'kind' , 'refId' ] ) ;
151- expect ( ClickedLinkEventTC . getFieldNames ( ) ) . toEqual ( [ '_id' , 'kind' , 'refId' , 'url' ] ) ;
152- } ) ;
153-
154- it ( 'manually override resolver output type for findMany' , async ( ) => {
155- // let's check graphql response
156-
157- await Event . create ( { refId : 'aaa' } ) ;
158- await Event . create ( { refId : 'bbb' } ) ;
159- await ClickedLinkEvent . create ( { refId : 'ccc' , url : 'url1' } ) ;
160- await ClickedLinkEvent . create ( { refId : 'ddd' , url : 'url2' } ) ;
161-
162- schemaComposer . rootQuery ( ) . addFields ( {
163- eventFindMany : EventTC . getResolver ( 'findMany' ) ,
164- } ) ;
165-
166- const schema = schemaComposer . buildSchema ( ) ;
167-
168- const res = await graphql . graphql (
169- schema ,
170- `{
171- eventFindMany {
172- __typename
173- ... on GenericEvent {
174- refId
175- }
176- ... on ClickedLinkEvent {
177- kind
178- refId
179- url
180- }
181- }
182- }`
183- ) ;
184-
185- expect ( res . errors [ 0 ] . message ) . toEqual ( 'Unknown type "GenericEvent".' ) ;
186- expect ( res . errors [ 1 ] . message ) . toEqual ( 'Unknown type "ClickedLinkEvent".' ) ;
187- } ) ;
188- } ) ;
18977} ) ;
0 commit comments