@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devticon-os/graphql-codegen-axios",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "license": "MIT",
5
5
  "main": "src/index.js",
6
6
  "repository": "https://github.com/devticon/graphql-codegen-axios",
package/src/index.js CHANGED
@@ -66,7 +66,7 @@ module.exports = {
66
66
  renderHeader('HELPERS'),
67
67
  helpers,
68
68
  renderHeader('Scalars'),
69
- renderScalars(scalars),
69
+ renderScalars(scalars, config),
70
70
  renderHeader('Enum'),
71
71
  ...enums.map(e => renderEnum(e, config)),
72
72
  renderHeader('FRAGMENTS'),
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, map = {}) => {
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
- ...map,
102
+ ...(config.scalars || {}),
102
103
  };
103
104
  return `export type Scalar = {${scalars
104
105
  .map(({ name }) => {