@@ -33,7 +33,7 @@ describe('jsonToGraphQL()', () => {
33
33
}
34
34
} ;
35
35
expect ( jsonToGraphQLQuery ( query , { pretty : true } ) ) . to . equal (
36
- `query {
36
+ `query {
37
37
Posts {
38
38
id
39
39
title
@@ -57,7 +57,7 @@ describe('jsonToGraphQL()', () => {
57
57
}
58
58
} ;
59
59
expect ( jsonToGraphQLQuery ( query , { pretty : true } ) ) . to . equal (
60
- `query {
60
+ `query {
61
61
Posts (orderBy: "post_date", userId: 12) {
62
62
id
63
63
title
@@ -84,7 +84,7 @@ describe('jsonToGraphQL()', () => {
84
84
}
85
85
} ;
86
86
expect ( jsonToGraphQLQuery ( query , { pretty : true } ) ) . to . equal (
87
- `query {
87
+ `query {
88
88
Posts (where: {published: true, rating: {_gt: 3}}, orderBy: "post_date") {
89
89
id
90
90
title
@@ -111,7 +111,7 @@ describe('jsonToGraphQL()', () => {
111
111
}
112
112
} ;
113
113
expect ( jsonToGraphQLQuery ( query , { pretty : true } ) ) . to . equal (
114
- `query {
114
+ `query {
115
115
Posts (or: [{published: true}, {rating: [{_gt: 3}]}], orderBy: "post_date") {
116
116
id
117
117
title
@@ -137,7 +137,7 @@ describe('jsonToGraphQL()', () => {
137
137
}
138
138
} as any ;
139
139
expect ( jsonToGraphQLQuery ( query , { pretty : true } ) ) . to . equal (
140
- `query {
140
+ `query {
141
141
Posts (where: {id: null}, orderBy: null) {
142
142
id
143
143
title
@@ -166,7 +166,7 @@ describe('jsonToGraphQL()', () => {
166
166
}
167
167
} as any ;
168
168
expect ( jsonToGraphQLQuery ( query , { pretty : true } ) ) . to . equal (
169
- `query {
169
+ `query {
170
170
Posts @client (where: {id: 10}, orderBy: "flibble") {
171
171
id
172
172
title
@@ -209,8 +209,8 @@ describe('jsonToGraphQL()', () => {
209
209
}
210
210
} ;
211
211
const expected = 'query { diet @client { id options { ' +
212
- 'mood { category id selected } weight { category icon id text } } ' +
213
- 'title } someOtherAbritraryKey @client { arb1 arb2 } }' ;
212
+ 'mood { category id selected } weight { category icon id text } } ' +
213
+ 'title } someOtherAbritraryKey @client { arb1 arb2 } }' ;
214
214
expect ( jsonToGraphQLQuery ( query ) ) . to . equal ( expected ) ;
215
215
} ) ;
216
216
@@ -260,7 +260,7 @@ describe('jsonToGraphQL()', () => {
260
260
}
261
261
} ;
262
262
expect ( jsonToGraphQLQuery ( query , { pretty : true } ) ) . to . equal (
263
- `query {
263
+ `query {
264
264
Posts {
265
265
id
266
266
title
@@ -295,7 +295,7 @@ describe('jsonToGraphQL()', () => {
295
295
}
296
296
} ;
297
297
expect ( jsonToGraphQLQuery ( query , { pretty : true } ) ) . to . equal (
298
- `query {
298
+ `query {
299
299
Posts (arg1: 20, arg2: "flibble") {
300
300
id
301
301
title
@@ -320,7 +320,7 @@ describe('jsonToGraphQL()', () => {
320
320
}
321
321
} ;
322
322
expect ( jsonToGraphQLQuery ( query , { pretty : true } ) ) . to . equal (
323
- `mutation {
323
+ `mutation {
324
324
create_post (title: "My Awesome Post", body: "This post is awesome!")
325
325
}` ) ;
326
326
} ) ;
@@ -385,24 +385,24 @@ describe('jsonToGraphQL()', () => {
385
385
} ) ;
386
386
387
387
it ( 'does not include fields which value is false' , ( ) => {
388
- const query = {
389
- query : {
390
- Posts : {
391
- __args : {
392
- a : false
388
+ const query = {
389
+ query : {
390
+ Posts : {
391
+ __args : {
392
+ a : false
393
+ } ,
394
+ id : true ,
395
+ name : false
393
396
} ,
394
- id : true ,
395
- name : false
396
- } ,
397
- Lorem : {
398
- id : true
399
- } ,
400
- Ipsum : false
401
- }
402
- } ;
403
- expect ( jsonToGraphQLQuery ( query ) ) . to . equal (
404
- 'query { Posts (a: false) { id } Lorem { id } }'
405
- ) ;
397
+ Lorem : {
398
+ id : true
399
+ } ,
400
+ Ipsum : false
401
+ }
402
+ } ;
403
+ expect ( jsonToGraphQLQuery ( query ) ) . to . equal (
404
+ 'query { Posts (a: false) { id } Lorem { id } }'
405
+ ) ;
406
406
} ) ;
407
407
408
408
it ( 'ignores a field that exists in the initial object' , ( ) => {
@@ -434,33 +434,33 @@ describe('jsonToGraphQL()', () => {
434
434
it ( 'supports inline fragments' , ( ) => {
435
435
const query = {
436
436
query : {
437
- lorem : {
437
+ Posts : {
438
438
__on : {
439
- __fragmentName : "subQuery " ,
439
+ __fragmentName : "ConfigurablePost " ,
440
440
id : true
441
441
}
442
- } ,
442
+ }
443
443
}
444
444
} ;
445
445
expect ( jsonToGraphQLQuery ( query ) ) . to . equal (
446
- 'query { lorem { ... on subQuery { id } } }'
446
+ 'query { Posts { ... on ConfigurablePost { id } } }'
447
447
) ;
448
448
} ) ;
449
449
450
450
it ( 'supports inline fragments with subfields on same level' , ( ) => {
451
451
const query = {
452
452
query : {
453
- lorem : {
453
+ Posts : {
454
+ title : true ,
454
455
__on : {
455
- __fragmentName : "subQuery " ,
456
+ __fragmentName : "ConfigurablePost " ,
456
457
id : true
457
- } ,
458
- title : true
459
- } ,
458
+ }
459
+ }
460
460
}
461
461
} ;
462
462
expect ( jsonToGraphQLQuery ( query ) ) . to . equal (
463
- 'query { lorem { title ... on subQuery { id } } }'
463
+ 'query { Posts { title ... on ConfigurablePost { id } } }'
464
464
) ;
465
465
} ) ;
466
466
0 commit comments