Skip to content

Commit f666c37

Browse files
committed
Rename __fragmentName to __typeName and update CHANGELOG
1 parent 55c11b5 commit f666c37

File tree

5 files changed

+41
-37
lines changed

5 files changed

+41
-37
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11

22
# json-to-graphql-query Changelog
33

4+
## 1.8.0
5+
6+
* Added support for Inline Fragments. Thanks again @jeniffer9 :)
7+
48
## 1.7.0
59

610
* Added `__aliasFor` option. The old `__alias` syntax did not support more than one alias. Thanks @jeniffer9

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Supported Options:
3131
* Support for Enum values via [`EnumType`](#query-with-enum-values)
3232
* Support for variables via [`__variables`](#query-with-variables)
3333
* Support for simple directives (such as `@client`) via [`__directives`](#query-with-directives)
34-
* Support for inline fragments via [`__on.__fragmentName`](#query-with-inline-fragments)
34+
* Support for one or more inline fragments via [`__on.__typeName`](#query-with-inline-fragments)
3535

3636
## Recent Changes
3737

@@ -352,7 +352,7 @@ const query = {
352352
Posts: {
353353
title: true
354354
__on: {
355-
__fragmentName: "ConfigurablePost",
355+
__typeName: "ConfigurablePost",
356356
id: true
357357
}
358358
}
@@ -383,11 +383,11 @@ const query = {
383383
Posts: {
384384
__on: [
385385
{
386-
__fragmentName: "ConfigurablePost",
386+
__typeName: "ConfigurablePost",
387387
id: true
388388
},
389389
{
390-
__fragmentName: "UnconfigurablePost",
390+
__typeName: "UnconfigurablePost",
391391
name: true
392392
}]
393393
}

package.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
{
2-
"name": "json-to-graphql-query",
3-
"version": "1.8.0",
4-
"main": "lib/index.js",
5-
"license": "MIT",
6-
"scripts": {
7-
"build": "tslint -p . && rm -rf lib/ && tsc",
8-
"test": "mocha -r ts-node/register --recursive \"./src/**/__tests__/*\"",
9-
"test-watch": "mocha -r ts-node/register --recursive \"./src/**/__tests__/*\" --watch --watch-extensions ts,tsx",
10-
"prepublish": "npm run build && npm run test"
11-
},
12-
"typings": "lib/index.d.ts",
13-
"repository": {
14-
"type": "git",
15-
"url": "https://github.com/dupski/json-to-graphql-query.git"
16-
},
17-
"devDependencies": {
18-
"@types/chai": "^4.0.10",
19-
"@types/mocha": "^2.2.45",
20-
"chai": "^4.1.2",
21-
"mocha": "^4.1.0",
22-
"sinon": "^4.1.3",
23-
"ts-node": "^4.1.0",
24-
"tslint": "5.8.0",
25-
"typescript": "2.6.2"
26-
}
27-
}
2+
"name": "json-to-graphql-query",
3+
"version": "1.7.0",
4+
"main": "lib/index.js",
5+
"license": "MIT",
6+
"scripts": {
7+
"build": "tslint -p . && rm -rf lib/ && tsc",
8+
"test": "mocha -r ts-node/register --recursive \"./src/**/__tests__/*\"",
9+
"test-watch": "mocha -r ts-node/register --recursive \"./src/**/__tests__/*\" --watch --watch-extensions ts,tsx",
10+
"prepublish": "npm run build && npm run test"
11+
},
12+
"typings": "lib/index.d.ts",
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/dupski/json-to-graphql-query.git"
16+
},
17+
"devDependencies": {
18+
"@types/chai": "^4.0.10",
19+
"@types/mocha": "^2.2.45",
20+
"chai": "^4.1.2",
21+
"mocha": "^4.1.0",
22+
"sinon": "^4.1.3",
23+
"ts-node": "^4.1.0",
24+
"tslint": "5.8.0",
25+
"typescript": "2.6.2"
26+
}
27+
}

src/__tests__/jsonToGraphQLQuery.tests.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ describe('jsonToGraphQL()', () => {
436436
query: {
437437
Posts: {
438438
__on: {
439-
__fragmentName: 'ConfigurablePost',
439+
__typeName: 'ConfigurablePost',
440440
id: true
441441
}
442442
}
@@ -453,7 +453,7 @@ describe('jsonToGraphQL()', () => {
453453
Posts: {
454454
title: true,
455455
__on: {
456-
__fragmentName: 'ConfigurablePost',
456+
__typeName: 'ConfigurablePost',
457457
id: true
458458
}
459459
}
@@ -470,11 +470,11 @@ describe('jsonToGraphQL()', () => {
470470
Posts: {
471471
__on: [
472472
{
473-
__fragmentName: 'ConfigurablePost',
473+
__typeName: 'ConfigurablePost',
474474
id: true
475475
},
476476
{
477-
__fragmentName: 'UnconfigurablePost',
477+
__typeName: 'UnconfigurablePost',
478478
name: true
479479
}]
480480
}

src/jsonToGraphQLQuery.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { EnumType } from './types/EnumType';
22
import { VariableType } from './types/VariableType';
33

44
export const configFields = [
5-
'__args', '__alias', '__aliasFor', '__variables', '__directives', '__on', '__fragmentName'
5+
'__args', '__alias', '__aliasFor', '__variables', '__directives', '__on', '__typeName'
66
];
77

88
function stringify(obj_from_json: any): string {
@@ -128,10 +128,10 @@ function convertQuery(node: any, level: number, output: Array<[string, number]>,
128128
convertQuery(node[key], level + 1, output, options);
129129

130130
if (inlineFragmentsExist) {
131-
const inlineFragments: Array<{ __fragmentName: string }>
131+
const inlineFragments: Array<{ __typeName: string }>
132132
= node[key].__on instanceof Array ? node[key].__on : [node[key].__on];
133133
inlineFragments.forEach((inlineFragment) => {
134-
const name = inlineFragment.__fragmentName;
134+
const name = inlineFragment.__typeName;
135135
output.push([`... on ${name} {`, level + 1]);
136136
convertQuery(inlineFragment, level + 2, output, options);
137137
output.push(['}', level + 1]);

0 commit comments

Comments
 (0)