@devticon-os/graphql-codegen-axios 0.2.1 → 0.2.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/input.js +12 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devticon-os/graphql-codegen-axios",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "license": "MIT",
5
5
  "main": "src/index.js",
6
6
  "repository": "https://github.com/devticon/graphql-codegen-axios",
package/src/input.js CHANGED
@@ -7,7 +7,8 @@ const findUsageInputs = (document, schema) => {
7
7
  continue;
8
8
  }
9
9
  for (const variableDefinition of definition.variableDefinitions) {
10
- const name = variableDefinition.type.name.value;
10
+ const type = unpackVariableType(variableDefinition.type);
11
+ const name = type.name.value;
11
12
  const input = findInputInSchema(name, schema);
12
13
  if (input) {
13
14
  inputs.push(input);
@@ -60,4 +61,14 @@ const unpackInputType = type => {
60
61
  return type;
61
62
  };
62
63
 
64
+ const unpackVariableType = type => {
65
+ if (type.kind === 'ListType') {
66
+ return unpackVariableType(type.type);
67
+ }
68
+ if (type.kind === 'NonNullType') {
69
+ return unpackVariableType(type.type);
70
+ }
71
+ return type;
72
+ };
73
+
63
74
  module.exports = { findUsageInputs, findInputInSchema };