@devticon-os/graphql-codegen-axios 0.2.11 → 0.2.12
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/enums.js +8 -1
- package/src/render.js +4 -3
- package/src/variables.js +2 -1
package/package.json
CHANGED
package/src/enums.js
CHANGED
|
@@ -25,4 +25,11 @@ const findEnumInType = (type, schema, ignore) => {
|
|
|
25
25
|
}
|
|
26
26
|
return enums;
|
|
27
27
|
};
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
const findEnumInSchema = (name, schema) => {
|
|
30
|
+
const type = schema._typeMap[name];
|
|
31
|
+
if (type instanceof GraphQLEnumType) {
|
|
32
|
+
return type;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
module.exports = { findUsageEnums, findEnumInSchema };
|
package/src/render.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { print } = require('graphql/index');
|
|
2
2
|
const { getUsedFragments } = require('./query');
|
|
3
|
-
const { GraphQLInputObjectType } = require('graphql/type');
|
|
3
|
+
const { GraphQLInputObjectType, GraphQLEnumType } = require('graphql/type');
|
|
4
|
+
const { get } = require('axios');
|
|
4
5
|
|
|
5
6
|
const getName = (name, type, config) => {
|
|
6
7
|
const suffix = config.suffix ? config.suffix[type] || '' : '';
|
|
@@ -36,8 +37,8 @@ const renderTypeField = (fields, config) => {
|
|
|
36
37
|
} else if (inLine) {
|
|
37
38
|
tsType += gqlType ? getName(typeName, gqlType, config) : typeName;
|
|
38
39
|
} else {
|
|
39
|
-
if (type instanceof GraphQLInputObjectType) {
|
|
40
|
-
tsType += typeName;
|
|
40
|
+
if (type instanceof GraphQLInputObjectType || type instanceof GraphQLEnumType) {
|
|
41
|
+
tsType += gqlType ? getName(typeName, gqlType, config) : typeName;
|
|
41
42
|
} else {
|
|
42
43
|
tsType += `{${renderTypeField(fields)}}`;
|
|
43
44
|
}
|
package/src/variables.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { findInputInSchema } = require('./input');
|
|
2
2
|
const { getGraphqlType } = require('./types');
|
|
3
|
+
const { findEnumInSchema } = require('./enums');
|
|
3
4
|
const getVariablesFields = (definition, schema) => {
|
|
4
5
|
return definition.variableDefinitions.map(variable => ({
|
|
5
6
|
name: variable.variable.name.value,
|
|
@@ -18,7 +19,7 @@ const getVariableType = (type, schema, isList = false, isNullable = true) => {
|
|
|
18
19
|
return getVariableType(type.type, schema, isList, isNullable);
|
|
19
20
|
}
|
|
20
21
|
const typeName = type.name.value;
|
|
21
|
-
const isScalar = !findInputInSchema(typeName, schema);
|
|
22
|
+
const isScalar = !findInputInSchema(typeName, schema) && !findEnumInSchema(typeName, schema);
|
|
22
23
|
return {
|
|
23
24
|
type: type.type,
|
|
24
25
|
isList,
|