graphql-data-generator 0.4.2-alpha.3 → 0.4.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.
- package/esm/proxy.js +11 -11
- package/package.json +1 -1
- package/script/proxy.js +11 -11
package/esm/proxy.js
CHANGED
|
@@ -524,28 +524,22 @@ export const _proxy = (definitions, scalars, path, patches, { prev, resolvedType
|
|
|
524
524
|
continue;
|
|
525
525
|
}
|
|
526
526
|
const isNonNull = variableDefinition.type.kind === Kind.NON_NULL_TYPE;
|
|
527
|
+
// Use default value if available if specified
|
|
528
|
+
if (variableDefinition.defaultValue) {
|
|
529
|
+
mock.variables[name] = constToValue(variableDefinition.defaultValue);
|
|
530
|
+
continue;
|
|
531
|
+
}
|
|
527
532
|
// For nullable variables, clear means undefined
|
|
528
533
|
if (!isNonNull) {
|
|
529
534
|
delete mock.variables[name];
|
|
530
535
|
continue;
|
|
531
536
|
}
|
|
532
|
-
// For non-nullable variables, use default value if available
|
|
533
|
-
if (variableDefinition.defaultValue) {
|
|
534
|
-
mock.variables[name] = constToValue(variableDefinition.defaultValue);
|
|
535
|
-
continue;
|
|
536
|
-
}
|
|
537
537
|
// Generate a default value based on the type
|
|
538
538
|
const result = resolveValue(definitions, scalars, variableDefinition.type, { hostType: `${path}Variables`, prop: name, input: false });
|
|
539
539
|
mock.variables[name] = result;
|
|
540
540
|
continue;
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
|
-
if (variableDefinition.defaultValue) {
|
|
544
|
-
if (!mock.variables)
|
|
545
|
-
mock.variables = {};
|
|
546
|
-
mock.variables[name] = constToValue(variableDefinition.defaultValue);
|
|
547
|
-
continue;
|
|
548
|
-
}
|
|
549
543
|
}
|
|
550
544
|
if (mockPrev?.variables && name in mockPrev.variables) {
|
|
551
545
|
if (!mock.variables)
|
|
@@ -553,6 +547,12 @@ export const _proxy = (definitions, scalars, path, patches, { prev, resolvedType
|
|
|
553
547
|
mock.variables[name] = mockPrev.variables[name];
|
|
554
548
|
continue;
|
|
555
549
|
}
|
|
550
|
+
if (variableDefinition.defaultValue) {
|
|
551
|
+
if (!mock.variables)
|
|
552
|
+
mock.variables = {};
|
|
553
|
+
mock.variables[name] = constToValue(variableDefinition.defaultValue);
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
556
|
const result = resolveValue(definitions, scalars, variableDefinition.type, { hostType: `${path}Variables`, prop: name, input: false });
|
|
557
557
|
if (result != null) {
|
|
558
558
|
if (!mock.variables)
|
package/package.json
CHANGED
package/script/proxy.js
CHANGED
|
@@ -528,28 +528,22 @@ const _proxy = (definitions, scalars, path, patches, { prev, resolvedType = reso
|
|
|
528
528
|
continue;
|
|
529
529
|
}
|
|
530
530
|
const isNonNull = variableDefinition.type.kind === graphql_1.Kind.NON_NULL_TYPE;
|
|
531
|
+
// Use default value if available if specified
|
|
532
|
+
if (variableDefinition.defaultValue) {
|
|
533
|
+
mock.variables[name] = constToValue(variableDefinition.defaultValue);
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
531
536
|
// For nullable variables, clear means undefined
|
|
532
537
|
if (!isNonNull) {
|
|
533
538
|
delete mock.variables[name];
|
|
534
539
|
continue;
|
|
535
540
|
}
|
|
536
|
-
// For non-nullable variables, use default value if available
|
|
537
|
-
if (variableDefinition.defaultValue) {
|
|
538
|
-
mock.variables[name] = constToValue(variableDefinition.defaultValue);
|
|
539
|
-
continue;
|
|
540
|
-
}
|
|
541
541
|
// Generate a default value based on the type
|
|
542
542
|
const result = resolveValue(definitions, scalars, variableDefinition.type, { hostType: `${path}Variables`, prop: name, input: false });
|
|
543
543
|
mock.variables[name] = result;
|
|
544
544
|
continue;
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
|
-
if (variableDefinition.defaultValue) {
|
|
548
|
-
if (!mock.variables)
|
|
549
|
-
mock.variables = {};
|
|
550
|
-
mock.variables[name] = constToValue(variableDefinition.defaultValue);
|
|
551
|
-
continue;
|
|
552
|
-
}
|
|
553
547
|
}
|
|
554
548
|
if (mockPrev?.variables && name in mockPrev.variables) {
|
|
555
549
|
if (!mock.variables)
|
|
@@ -557,6 +551,12 @@ const _proxy = (definitions, scalars, path, patches, { prev, resolvedType = reso
|
|
|
557
551
|
mock.variables[name] = mockPrev.variables[name];
|
|
558
552
|
continue;
|
|
559
553
|
}
|
|
554
|
+
if (variableDefinition.defaultValue) {
|
|
555
|
+
if (!mock.variables)
|
|
556
|
+
mock.variables = {};
|
|
557
|
+
mock.variables[name] = constToValue(variableDefinition.defaultValue);
|
|
558
|
+
continue;
|
|
559
|
+
}
|
|
560
560
|
const result = resolveValue(definitions, scalars, variableDefinition.type, { hostType: `${path}Variables`, prop: name, input: false });
|
|
561
561
|
if (result != null) {
|
|
562
562
|
if (!mock.variables)
|