Skip to content

Commit d5e1fae

Browse files
author
Jeniffer Lima Graf
committed
updates version
1 parent 95a07a4 commit d5e1fae

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-to-graphql-query",
3-
"version": "1.7.0",
3+
"version": "1.8.0",
44
"main": "lib/index.js",
55
"license": "MIT",
66
"scripts": {

src/__tests__/jsonToGraphQLQuery.tests.ts

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('jsonToGraphQL()', () => {
3333
}
3434
};
3535
expect(jsonToGraphQLQuery(query, { pretty: true })).to.equal(
36-
`query {
36+
`query {
3737
Posts {
3838
id
3939
title
@@ -57,7 +57,7 @@ describe('jsonToGraphQL()', () => {
5757
}
5858
};
5959
expect(jsonToGraphQLQuery(query, { pretty: true })).to.equal(
60-
`query {
60+
`query {
6161
Posts (orderBy: "post_date", userId: 12) {
6262
id
6363
title
@@ -84,7 +84,7 @@ describe('jsonToGraphQL()', () => {
8484
}
8585
};
8686
expect(jsonToGraphQLQuery(query, { pretty: true })).to.equal(
87-
`query {
87+
`query {
8888
Posts (where: {published: true, rating: {_gt: 3}}, orderBy: "post_date") {
8989
id
9090
title
@@ -111,7 +111,7 @@ describe('jsonToGraphQL()', () => {
111111
}
112112
};
113113
expect(jsonToGraphQLQuery(query, { pretty: true })).to.equal(
114-
`query {
114+
`query {
115115
Posts (or: [{published: true}, {rating: [{_gt: 3}]}], orderBy: "post_date") {
116116
id
117117
title
@@ -137,7 +137,7 @@ describe('jsonToGraphQL()', () => {
137137
}
138138
} as any;
139139
expect(jsonToGraphQLQuery(query, { pretty: true })).to.equal(
140-
`query {
140+
`query {
141141
Posts (where: {id: null}, orderBy: null) {
142142
id
143143
title
@@ -166,7 +166,7 @@ describe('jsonToGraphQL()', () => {
166166
}
167167
} as any;
168168
expect(jsonToGraphQLQuery(query, { pretty: true })).to.equal(
169-
`query {
169+
`query {
170170
Posts @client (where: {id: 10}, orderBy: "flibble") {
171171
id
172172
title
@@ -209,8 +209,8 @@ describe('jsonToGraphQL()', () => {
209209
}
210210
};
211211
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 } }';
214214
expect(jsonToGraphQLQuery(query)).to.equal(expected);
215215
});
216216

@@ -260,7 +260,7 @@ describe('jsonToGraphQL()', () => {
260260
}
261261
};
262262
expect(jsonToGraphQLQuery(query, { pretty: true })).to.equal(
263-
`query {
263+
`query {
264264
Posts {
265265
id
266266
title
@@ -295,7 +295,7 @@ describe('jsonToGraphQL()', () => {
295295
}
296296
};
297297
expect(jsonToGraphQLQuery(query, { pretty: true })).to.equal(
298-
`query {
298+
`query {
299299
Posts (arg1: 20, arg2: "flibble") {
300300
id
301301
title
@@ -320,7 +320,7 @@ describe('jsonToGraphQL()', () => {
320320
}
321321
};
322322
expect(jsonToGraphQLQuery(query, { pretty: true })).to.equal(
323-
`mutation {
323+
`mutation {
324324
create_post (title: "My Awesome Post", body: "This post is awesome!")
325325
}`);
326326
});
@@ -385,24 +385,24 @@ describe('jsonToGraphQL()', () => {
385385
});
386386

387387
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
393396
},
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+
);
406406
});
407407

408408
it('ignores a field that exists in the initial object', () => {
@@ -434,33 +434,33 @@ describe('jsonToGraphQL()', () => {
434434
it('supports inline fragments', () => {
435435
const query = {
436436
query: {
437-
lorem: {
437+
Posts: {
438438
__on: {
439-
__fragmentName: "subQuery",
439+
__fragmentName: "ConfigurablePost",
440440
id: true
441441
}
442-
},
442+
}
443443
}
444444
};
445445
expect(jsonToGraphQLQuery(query)).to.equal(
446-
'query { lorem { ... on subQuery { id } } }'
446+
'query { Posts { ... on ConfigurablePost { id } } }'
447447
);
448448
});
449449

450450
it('supports inline fragments with subfields on same level', () => {
451451
const query = {
452452
query: {
453-
lorem: {
453+
Posts: {
454+
title: true,
454455
__on: {
455-
__fragmentName: "subQuery",
456+
__fragmentName: "ConfigurablePost",
456457
id: true
457-
},
458-
title: true
459-
},
458+
}
459+
}
460460
}
461461
};
462462
expect(jsonToGraphQLQuery(query)).to.equal(
463-
'query { lorem { title ... on subQuery { id } } }'
463+
'query { Posts { title ... on ConfigurablePost { id } } }'
464464
);
465465
});
466466

0 commit comments

Comments
 (0)