graphql-data-generator 0.4.4 → 0.4.5

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/codegen.js CHANGED
@@ -308,7 +308,9 @@ const fillOutInput = (input, inputs, references) => {
308
308
  const def = inputs[input.value];
309
309
  if (!def)
310
310
  return input;
311
- return serializeInput(def[0].fields ?? [], input.optional, inputs, references);
311
+ // For input types, expand to Object (this signals that it's an input type)
312
+ // but don't recursively expand nested input types to avoid infinite recursion
313
+ return serializeInput(def[0].fields ?? [], input.optional, {}, references);
312
314
  }
313
315
  case "Union":
314
316
  return {
@@ -502,8 +504,14 @@ export const codegen = (schema, files, { enums = "literals", scalars, includeTyp
502
504
  if (handledInputs.has(type.value) || !inputs[type.value])
503
505
  return;
504
506
  const stack = [type.value];
507
+ const seen = new Set();
505
508
  while (stack.length) {
506
509
  const current = stack.pop();
510
+ if (seen.has(current)) {
511
+ handledInputs.add(current);
512
+ continue;
513
+ }
514
+ seen.add(current);
507
515
  const def = inputs[current]?.[0];
508
516
  if (!def) {
509
517
  throw new Error(`Could not find nested input '${current}'`);
@@ -517,7 +525,7 @@ export const codegen = (schema, files, { enums = "literals", scalars, includeTyp
517
525
  type = type.type;
518
526
  }
519
527
  return type.name.value;
520
- }).filter((t) => inputs[t]) ?? [];
528
+ }).filter((t) => inputs[t] && !seen.has(t)) ?? [];
521
529
  if (subFieldTypes.some((t) => !handledInputs.has(t))) {
522
530
  stack.push(current);
523
531
  stack.push(...subFieldTypes);
package/esm/jest.js CHANGED
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file jsx-no-useless-fragment no-unused-vars
1
2
  import * as dntShim from "./_dnt.shims.js";
2
3
  import React, { useMemo } from "react";
3
4
  import { ApolloLink, useApolloClient, } from "@apollo/client";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql-data-generator",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/voces/graphql-data-generator.git"
package/script/codegen.js CHANGED
@@ -314,7 +314,9 @@ const fillOutInput = (input, inputs, references) => {
314
314
  const def = inputs[input.value];
315
315
  if (!def)
316
316
  return input;
317
- return serializeInput(def[0].fields ?? [], input.optional, inputs, references);
317
+ // For input types, expand to Object (this signals that it's an input type)
318
+ // but don't recursively expand nested input types to avoid infinite recursion
319
+ return serializeInput(def[0].fields ?? [], input.optional, {}, references);
318
320
  }
319
321
  case "Union":
320
322
  return {
@@ -508,8 +510,14 @@ const codegen = (schema, files, { enums = "literals", scalars, includeTypenames
508
510
  if (handledInputs.has(type.value) || !inputs[type.value])
509
511
  return;
510
512
  const stack = [type.value];
513
+ const seen = new Set();
511
514
  while (stack.length) {
512
515
  const current = stack.pop();
516
+ if (seen.has(current)) {
517
+ handledInputs.add(current);
518
+ continue;
519
+ }
520
+ seen.add(current);
513
521
  const def = inputs[current]?.[0];
514
522
  if (!def) {
515
523
  throw new Error(`Could not find nested input '${current}'`);
@@ -523,7 +531,7 @@ const codegen = (schema, files, { enums = "literals", scalars, includeTypenames
523
531
  type = type.type;
524
532
  }
525
533
  return type.name.value;
526
- }).filter((t) => inputs[t]) ?? [];
534
+ }).filter((t) => inputs[t] && !seen.has(t)) ?? [];
527
535
  if (subFieldTypes.some((t) => !handledInputs.has(t))) {
528
536
  stack.push(current);
529
537
  stack.push(...subFieldTypes);
package/script/jest.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // deno-lint-ignore-file jsx-no-useless-fragment no-unused-vars
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
4
5
  var desc = Object.getOwnPropertyDescriptor(m, k);