@vladimirdev635/gql-codegen 0.0.93 → 0.0.94

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.
@@ -3,6 +3,7 @@ import { getScalarSpecFromMapping } from './scalars/mapping.js';
3
3
  import ts from 'typescript';
4
4
  import { generateSchemaName, generateZodInferTypeAlias } from './shared.js';
5
5
  import { assertUnreachable } from '../../../../../utils.js';
6
+ import { invokeMethod } from '../../../shared.js';
6
7
  function generateZodObjectTypeSpec(scalarsMapping, type) {
7
8
  switch (type._type) {
8
9
  case 'Enum': {
@@ -50,7 +51,10 @@ export function generateZodObjectFieldSpec(scalarsMapping, field) {
50
51
  assertUnreachable(field.spec);
51
52
  }
52
53
  }
53
- return expression;
54
+ if (!field.nullable) {
55
+ return expression;
56
+ }
57
+ return invokeMethod(invokeMethod(expression, 'nullable', []), 'optional', []);
54
58
  }
55
59
  const lazyTypes = [
56
60
  'ObjectType',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vladimirdev635/gql-codegen",
3
- "version": "0.0.93",
3
+ "version": "0.0.94",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
package/schema/utils.js CHANGED
@@ -100,10 +100,10 @@ function extractFieldFromNonCallableFieldSpec(spec) {
100
100
  ;
101
101
  function buildInputFieldSpec(spec) {
102
102
  switch (spec._type) {
103
- case 'literal': return spec.type._type;
103
+ case 'literal': return spec.type.name;
104
104
  case 'array':
105
105
  return '[' + buildInputFieldSpec(spec.type) +
106
- spec.nullable ? '' : '!' + ']';
106
+ (spec.nullable ? '' : '!') + ']';
107
107
  }
108
108
  }
109
109
  function buildInputField(field) {