@devticon-os/graphql-codegen-axios 0.2.15 → 0.2.17

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.15",
3
+ "version": "0.2.17",
4
4
  "license": "MIT",
5
5
  "main": "src/index.js",
6
6
  "repository": "https://github.com/devticon/graphql-codegen-axios",
package/src/helpers.ts CHANGED
@@ -44,8 +44,7 @@ export const unpackSingleResults = (key: string) => (data: any) => data[key];
44
44
 
45
45
  export class GraphqlError extends Error {
46
46
  constructor(message: string, public gqlErrors: GraphQLError[]) {
47
- const msg = `${message} ${gqlErrors.map(e => e.message).join('\n')}`;
48
- super(msg);
47
+ super(`${message} ${gqlErrors.map(e => e.message).join('\n')}`);
49
48
  }
50
49
  }
51
50
 
package/src/index.js CHANGED
@@ -19,14 +19,14 @@ const { getFunctionChain, isSingleResultOperation } = require('./functions');
19
19
  const { capitalize } = require('./utils');
20
20
 
21
21
  const helpers = fs.readFileSync(path.join(__dirname, 'helpers.ts'), 'utf-8');
22
- const directives = ` directive @first on OBJECT
23
- directive @firstOrFail on OBJECT
24
- directive @singleResult on OBJECT
25
- directive @nonNullable on OBJECT`;
22
+ const directives = `directive @first on FIELD
23
+ directive @firstOrFail on FIELD
24
+ directive @singleResult on QUERY | MUTATION
25
+ directive @nonNullable on FIELD`;
26
26
  module.exports = {
27
27
  plugin(schema, documents, config) {
28
28
  try {
29
- fs.writeFileSync('directives.graphql', directives);
29
+ fs.writeFileSync(path.join(config.directivesFilePath || '', 'directives.graphql'), directives);
30
30
  const functions = [];
31
31
  const queries = [];
32
32
  const inputs = findUsageInputs(documents, schema);
package/src/render.js CHANGED
@@ -2,6 +2,7 @@ const { print } = require('graphql/index');
2
2
  const { getUsedFragments } = require('./query');
3
3
  const { GraphQLInputObjectType, GraphQLEnumType } = require('graphql/type');
4
4
  const { get } = require('axios');
5
+ const { capitalize } = require('./utils');
5
6
 
6
7
  const getName = (name, type, config) => {
7
8
  const suffix = config.suffix ? config.suffix[type] || '' : '';
@@ -90,7 +91,7 @@ const getScalarTsType = name => `Scalar["${name}"]`;
90
91
  const renderEnum = (e, config) => {
91
92
  let str = `export enum ${getName(e.name, 'enum', config)} {`;
92
93
  for (let { name, value } of e.values) {
93
- str += `${name} = "${value}",`;
94
+ str += `${capitalize(name.toLowerCase())} = "${value}",`;
94
95
  }
95
96
  str += `};`;
96
97
  return str;