@vladimirdev635/gql-codegen 0.0.92 → 0.0.93
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.
|
@@ -33,7 +33,10 @@ function generateZodInputField(scalarsMapping, field) {
|
|
|
33
33
|
return invokeMethod(invokeMethod(expression, 'nullable', []), 'optional', []);
|
|
34
34
|
}
|
|
35
35
|
function isFieldLazy(spec) {
|
|
36
|
-
|
|
36
|
+
switch (spec._type) {
|
|
37
|
+
case 'literal': return spec.type._type === 'InputType';
|
|
38
|
+
case 'array': return isFieldLazy(spec.type);
|
|
39
|
+
}
|
|
37
40
|
}
|
|
38
41
|
export function generateInputTypeDefinitionFields(scalarsMapping, fields) {
|
|
39
42
|
return Object.entries(fields).map(([name, field]) => {
|
package/package.json
CHANGED
package/schema/utils.js
CHANGED
|
@@ -117,11 +117,11 @@ function buildInputField(field) {
|
|
|
117
117
|
;
|
|
118
118
|
function extractTypeFromObjectFieldSpec(spec) {
|
|
119
119
|
switch (spec._type) {
|
|
120
|
-
case 'literal':
|
|
120
|
+
case 'literal': return spec.type;
|
|
121
121
|
case 'array':
|
|
122
|
-
return spec.type;
|
|
122
|
+
return extractTypeFromObjectFieldSpec(spec.type);
|
|
123
123
|
case 'callable':
|
|
124
|
-
return spec.returnType
|
|
124
|
+
return extractTypeFromObjectFieldSpec(spec.returnType);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
function generateObjectFragmentSpecText(object, onlyField = null) {
|
|
@@ -157,28 +157,24 @@ function generateUnionFragmentSpecText(union) {
|
|
|
157
157
|
}
|
|
158
158
|
export function buildSelectionFromFieldSpec(spec) {
|
|
159
159
|
const type = extractTypeFromObjectFieldSpec(spec);
|
|
160
|
-
|
|
161
|
-
return buildSelectionFromFieldSpec(type.type);
|
|
162
|
-
if (type._type !== 'literal')
|
|
163
|
-
throw new Error('Unexpected condition');
|
|
164
|
-
switch (type.type._type) {
|
|
160
|
+
switch (type._type) {
|
|
165
161
|
case 'Enum':
|
|
166
162
|
case 'Scalar': return null;
|
|
167
163
|
case 'ObjectType':
|
|
168
164
|
case 'InterfaceType':
|
|
169
165
|
return {
|
|
170
166
|
_type: 'ObjectFragmentSpec',
|
|
171
|
-
name: type.
|
|
167
|
+
name: type.name,
|
|
172
168
|
selections: [
|
|
173
|
-
{ _type: 'SpreadSelection', fragment: type.
|
|
169
|
+
{ _type: 'SpreadSelection', fragment: type.name }
|
|
174
170
|
]
|
|
175
171
|
};
|
|
176
172
|
case 'Union':
|
|
177
173
|
return {
|
|
178
174
|
_type: 'UnionFragmentSpec',
|
|
179
|
-
name: type.
|
|
175
|
+
name: type.name,
|
|
180
176
|
selections: [
|
|
181
|
-
{ _type: 'SpreadSelection', fragment: type.
|
|
177
|
+
{ _type: 'SpreadSelection', fragment: type.name }
|
|
182
178
|
]
|
|
183
179
|
};
|
|
184
180
|
}
|