@snowtop/ent 0.1.0-alpha132 → 0.1.0-alpha134

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.
@@ -420,15 +420,29 @@ class GQLCapture {
420
420
  if (inter) {
421
421
  const fields = this.customFields.get(inter.nodeName);
422
422
  if (fields) {
423
+ // check for duplicate fields
424
+ // if field is already defined no need to add it
423
425
  let objFields = this.customFields.get(obj.nodeName);
424
426
  if (!objFields) {
425
427
  objFields = [];
426
428
  }
429
+ let map = new Map();
430
+ for (const f of objFields) {
431
+ map.set(f.gqlName, f);
432
+ }
427
433
  for (const field of fields) {
428
- objFields.push({
434
+ const newField = {
429
435
  ...field,
430
436
  nodeName: obj.nodeName,
431
- });
437
+ };
438
+ if (map.has(field.gqlName)) {
439
+ const existing = map.get(field.gqlName);
440
+ if (JSON.stringify(existing) !== JSON.stringify(newField)) {
441
+ throw new Error(`object ${obj.nodeName} has duplicate field ${field.gqlName} with different definition`);
442
+ }
443
+ continue;
444
+ }
445
+ objFields.push(newField);
432
446
  }
433
447
  this.customFields.set(obj.nodeName, objFields);
434
448
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowtop/ent",
3
- "version": "0.1.0-alpha132",
3
+ "version": "0.1.0-alpha134",
4
4
  "description": "snowtop ent framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -8,6 +8,7 @@
8
8
  "example": "examples"
9
9
  },
10
10
  "dependencies": {
11
+ "@swc-node/register": "^1.6.5",
11
12
  "@types/node": "^18.11.18",
12
13
  "camel-case": "^4.1.2",
13
14
  "cosmiconfig": "^8.0.0",
@@ -149,12 +149,20 @@ async function captureDynamic(filePath, gqlCapture) {
149
149
  return;
150
150
  }
151
151
  return await new Promise((resolve, reject) => {
152
- // do we eventually need tsconfig-paths here or do we get it by default because child process?
153
- const args = ["--swc", filePath];
154
- if (process.env.DISABLE_SWC) {
155
- args.shift();
152
+ // we seem to get tsconfig-paths by default because child process but not 100% sure...
153
+ const args = ["--transpileOnly"];
154
+ const env = {
155
+ ...process.env,
156
+ };
157
+ if (!process.env.DISABLE_SWC) {
158
+ args.push("-r", "@swc-node/register");
159
+ env.SWCRC = "true";
156
160
  }
157
- const r = (0, child_process_1.spawn)("ts-node", args);
161
+ args.push(filePath);
162
+ console.error("running ts-node", args, env);
163
+ const r = (0, child_process_1.spawn)("ts-node", args, {
164
+ env,
165
+ });
158
166
  const datas = [];
159
167
  r.stdout.on("data", (data) => {
160
168
  datas.push(data.toString());