graphql-data-generator 0.4.2-alpha.0 → 0.4.2-alpha.1

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 CHANGED
@@ -519,7 +519,24 @@ export const _proxy = (definitions, scalars, path, patches, { prev, resolvedType
519
519
  if (value !== undefined) {
520
520
  if (!mock.variables)
521
521
  mock.variables = {};
522
- mock.variables[name] = value;
522
+ if (value !== clear) {
523
+ mock.variables[name] = value;
524
+ continue;
525
+ }
526
+ const isNonNull = variableDefinition.type.kind === Kind.NON_NULL_TYPE;
527
+ // For nullable variables, clear means undefined
528
+ if (!isNonNull) {
529
+ delete mock.variables[name];
530
+ continue;
531
+ }
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
+ // Generate a default value based on the type
538
+ const result = resolveValue(definitions, scalars, variableDefinition.type, { hostType: `${path}Variables`, prop: name, input: false });
539
+ mock.variables[name] = result;
523
540
  continue;
524
541
  }
525
542
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql-data-generator",
3
- "version": "0.4.2-alpha.0",
3
+ "version": "0.4.2-alpha.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/voces/graphql-data-generator.git"
@@ -46,6 +46,7 @@
46
46
  }
47
47
  },
48
48
  "dependencies": {
49
+ "@apollo/client": "3",
49
50
  "@graphql-codegen/visitor-plugin-common": "*",
50
51
  "fast-glob": "*",
51
52
  "jest-diff": "*",
@@ -60,7 +61,6 @@
60
61
  "@graphql-tools/graphql-tag-pluck": "*",
61
62
  "react": "*",
62
63
  "@types/react": "*",
63
- "@apollo/client": "*",
64
64
  "@testing-library/dom": "*",
65
65
  "@testing-library/react": "*"
66
66
  },
@@ -71,7 +71,7 @@
71
71
  "@types/react": {
72
72
  "optional": true
73
73
  },
74
- "@apollo/client": {
74
+ "@apollo/client@3": {
75
75
  "optional": true
76
76
  },
77
77
  "@testing-library/dom": {
package/script/proxy.js CHANGED
@@ -523,7 +523,24 @@ const _proxy = (definitions, scalars, path, patches, { prev, resolvedType = reso
523
523
  if (value !== undefined) {
524
524
  if (!mock.variables)
525
525
  mock.variables = {};
526
- mock.variables[name] = value;
526
+ if (value !== exports.clear) {
527
+ mock.variables[name] = value;
528
+ continue;
529
+ }
530
+ const isNonNull = variableDefinition.type.kind === graphql_1.Kind.NON_NULL_TYPE;
531
+ // For nullable variables, clear means undefined
532
+ if (!isNonNull) {
533
+ delete mock.variables[name];
534
+ continue;
535
+ }
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
+ // Generate a default value based on the type
542
+ const result = resolveValue(definitions, scalars, variableDefinition.type, { hostType: `${path}Variables`, prop: name, input: false });
543
+ mock.variables[name] = result;
527
544
  continue;
528
545
  }
529
546
  }