graphql-data-generator 0.2.2 → 0.2.3

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
@@ -289,7 +289,9 @@ const defaultScalars = {
289
289
  ID: "string",
290
290
  };
291
291
  export const codegen = (schema, files, { enums = "literals", scalars, includeTypenames = true, exports = [], typesFile, namingConvention = "keep", } = {}) => {
292
- const rename = convertFactory({ namingConvention });
292
+ const rename = typesFile
293
+ ? convertFactory({ namingConvention })
294
+ : (v) => v;
293
295
  const schemaDoc = parse(typeof schema === "string" ? schema : printSchema(schema));
294
296
  scalars = { ...defaultScalars, ...scalars };
295
297
  const types = {};
@@ -391,6 +393,10 @@ export const codegen = (schema, files, { enums = "literals", scalars, includeTyp
391
393
  console.warn(`Skipping unnamed operation in '${path}'`);
392
394
  continue;
393
395
  }
396
+ if (operations[definition.operation].some((o) => o.name === name)) {
397
+ console.warn(`Skipping duplicate operation '${name}'`);
398
+ continue;
399
+ }
394
400
  operations[definition.operation].push({
395
401
  name,
396
402
  path,
@@ -501,7 +507,7 @@ ${collection.map((o) => ` ${o.name}: "${relative(process.cwd(), o.path)}",`).jo
501
507
  throw new Error(`Could not find input '${i}'`);
502
508
  return `${exports.includes("types") ? "export " : ""}type ${i} = ${serializeType(serializeInput(def.fields ?? [], false, {}, references), true)};`;
503
509
  }).filter(filterOutputTypes), `export type Inputs = {
504
- ${Array.from(handledInputs).map((i) => ` ${i}: ${i};`).join("\n")}
510
+ ${Array.from(handledInputs).map((i) => ` ${i}: ${rename(i)};`).join("\n")}
505
511
  };`, `export const inputs = [${Array.from(handledInputs).map((i) => `"${i}"`).join(", ")}] as const;`);
506
512
  }
507
513
  const usedTypes = Object.entries(types)
package/esm/proxy.js CHANGED
@@ -62,7 +62,7 @@ const resolveType = (definitions, path) => {
62
62
  }
63
63
  type = argument.type;
64
64
  }
65
- while (parts[i + 2]?.match(/^\d$/)) {
65
+ while (parts[i + 2]?.match(/^\d+$/)) {
66
66
  if (type.kind === Kind.NON_NULL_TYPE)
67
67
  type = type.type;
68
68
  if (type.kind !== Kind.LIST_TYPE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql-data-generator",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/vocesgraphql-data-generator/.git"