graphql-data-generator 0.4.0-alpha.9 → 0.4.0

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/jest.js CHANGED
@@ -16,8 +16,8 @@ globalThis.jasmine
16
16
  specStarted: (result) => currentSpecResult = result,
17
17
  });
18
18
  const alreadyFailed = () => {
19
- if ((currentSpecResult?.failedExpectations.length ?? 0) > 0)
20
- return true;
19
+ if (currentSpecResult)
20
+ return currentSpecResult.failedExpectations.length > 0;
21
21
  const state = expect.getState();
22
22
  return state.assertionCalls > state.numPassingAsserts ||
23
23
  state.suppressedErrors.length > 0;
package/esm/proxy.js CHANGED
@@ -464,9 +464,9 @@ export const _proxy = (definitions, scalars, path, patches, { prev, resolvedType
464
464
  }
465
465
  case Kind.OPERATION_DEFINITION: {
466
466
  const mockPrev = prev;
467
- const { variables: _1, data: _2, error: _3, errors: _4, ...prevExtra } = mockPrev ?? {};
467
+ const { variables: _1, data: _2, ...prevExtra } = mockPrev ?? {};
468
468
  const mockPatch = patch;
469
- const { variables: _5, data: _6, error: _7, errors: _8, ...patchExtra } = mockPatch ?? {};
469
+ const { variables: _3, data: _4, error: _5, errors: _6, ...patchExtra } = mockPatch ?? {};
470
470
  const mock = { ...prevExtra, ...patchExtra, data: null };
471
471
  // const patch = patches[patches.length - 1] as Patch<Mock> | undefined;
472
472
  const variablePatch = typeof mockPatch?.variables === "function"
package/esm/util.js CHANGED
@@ -11,6 +11,12 @@ export const absurd = (v) => {
11
11
  Error.captureStackTrace(error, absurd);
12
12
  throw error;
13
13
  };
14
+ const isPlainObject = (value) => {
15
+ if (Object.prototype.toString.call(value) !== "[object Object]")
16
+ return false;
17
+ const proto = Object.getPrototypeOf(value);
18
+ return proto === Object.prototype || proto === null;
19
+ };
14
20
  export const toObject = (obj) => {
15
21
  if (typeof obj !== "object" || !obj) {
16
22
  return obj;
@@ -18,6 +24,8 @@ export const toObject = (obj) => {
18
24
  if (Array.isArray(obj)) {
19
25
  return obj.map(toObject);
20
26
  }
27
+ if (!isPlainObject(obj))
28
+ return obj;
21
29
  const clone = {};
22
30
  for (const key in obj) {
23
31
  if (typeof obj[key] !== "function") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql-data-generator",
3
- "version": "0.4.0-alpha.9",
3
+ "version": "0.4.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/voces/graphql-data-generator.git"
package/script/jest.js CHANGED
@@ -42,8 +42,8 @@ globalThis.jasmine
42
42
  specStarted: (result) => currentSpecResult = result,
43
43
  });
44
44
  const alreadyFailed = () => {
45
- if ((currentSpecResult?.failedExpectations.length ?? 0) > 0)
46
- return true;
45
+ if (currentSpecResult)
46
+ return currentSpecResult.failedExpectations.length > 0;
47
47
  const state = expect.getState();
48
48
  return state.assertionCalls > state.numPassingAsserts ||
49
49
  state.suppressedErrors.length > 0;
package/script/proxy.js CHANGED
@@ -468,9 +468,9 @@ const _proxy = (definitions, scalars, path, patches, { prev, resolvedType = reso
468
468
  }
469
469
  case graphql_1.Kind.OPERATION_DEFINITION: {
470
470
  const mockPrev = prev;
471
- const { variables: _1, data: _2, error: _3, errors: _4, ...prevExtra } = mockPrev ?? {};
471
+ const { variables: _1, data: _2, ...prevExtra } = mockPrev ?? {};
472
472
  const mockPatch = patch;
473
- const { variables: _5, data: _6, error: _7, errors: _8, ...patchExtra } = mockPatch ?? {};
473
+ const { variables: _3, data: _4, error: _5, errors: _6, ...patchExtra } = mockPatch ?? {};
474
474
  const mock = { ...prevExtra, ...patchExtra, data: null };
475
475
  // const patch = patches[patches.length - 1] as Patch<Mock> | undefined;
476
476
  const variablePatch = typeof mockPatch?.variables === "function"
package/script/util.js CHANGED
@@ -16,6 +16,12 @@ const absurd = (v) => {
16
16
  throw error;
17
17
  };
18
18
  exports.absurd = absurd;
19
+ const isPlainObject = (value) => {
20
+ if (Object.prototype.toString.call(value) !== "[object Object]")
21
+ return false;
22
+ const proto = Object.getPrototypeOf(value);
23
+ return proto === Object.prototype || proto === null;
24
+ };
19
25
  const toObject = (obj) => {
20
26
  if (typeof obj !== "object" || !obj) {
21
27
  return obj;
@@ -23,6 +29,8 @@ const toObject = (obj) => {
23
29
  if (Array.isArray(obj)) {
24
30
  return obj.map(exports.toObject);
25
31
  }
32
+ if (!isPlainObject(obj))
33
+ return obj;
26
34
  const clone = {};
27
35
  for (const key in obj) {
28
36
  if (typeof obj[key] !== "function") {