@devticon-os/graphql-codegen-axios 0.2.8 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +1 -1
- package/src/render.js +5 -4
package/package.json
CHANGED
package/src/index.js
CHANGED
package/src/render.js
CHANGED
|
@@ -3,7 +3,7 @@ const { getUsedFragments } = require('./query');
|
|
|
3
3
|
const { GraphQLInputObjectType } = require('graphql/type');
|
|
4
4
|
|
|
5
5
|
const getName = (name, type, config) => {
|
|
6
|
-
const suffix = config.suffix ? config.suffix[type] : '';
|
|
6
|
+
const suffix = config.suffix ? config.suffix[type] || '' : '';
|
|
7
7
|
return `${name}${suffix}`;
|
|
8
8
|
};
|
|
9
9
|
const renderType = ({ name, fields, union, isList, isNullable, gqlType }, config) => {
|
|
@@ -12,6 +12,7 @@ const renderType = ({ name, fields, union, isList, isNullable, gqlType }, config
|
|
|
12
12
|
tsType += [...union.map(u => getName(u, 'fragment', config)), ''].join(' & ');
|
|
13
13
|
}
|
|
14
14
|
tsType += `{${renderTypeField(fields, config)}}`;
|
|
15
|
+
tsType = `(${tsType})`;
|
|
15
16
|
if (isList) {
|
|
16
17
|
tsType += '[]';
|
|
17
18
|
}
|
|
@@ -92,13 +93,13 @@ const renderEnum = (e, config) => {
|
|
|
92
93
|
const renderFragment = fragment => {
|
|
93
94
|
return `export const ${fragment.name}FragmentQuery = \`${print(fragment.type)}\`;`;
|
|
94
95
|
};
|
|
95
|
-
const renderScalars = (scalars,
|
|
96
|
-
map = {
|
|
96
|
+
const renderScalars = (scalars, config = {}) => {
|
|
97
|
+
const map = {
|
|
97
98
|
String: 'string',
|
|
98
99
|
Boolean: 'boolean',
|
|
99
100
|
Int: 'number',
|
|
100
101
|
Float: 'number',
|
|
101
|
-
...
|
|
102
|
+
...(config.scalars || {}),
|
|
102
103
|
};
|
|
103
104
|
return `export type Scalar = {${scalars
|
|
104
105
|
.map(({ name }) => {
|