@snowtop/ent 0.1.0-alpha132 → 0.1.0-alpha133

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.
Files changed (2) hide show
  1. package/graphql/graphql.js +16 -2
  2. package/package.json +1 -1
@@ -420,15 +420,29 @@ class GQLCapture {
420
420
  if (inter) {
421
421
  const fields = this.customFields.get(inter.nodeName);
422
422
  if (fields) {
423
+ // TODO check for duplicate fields
424
+ // e.g. 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-alpha133",
4
4
  "description": "snowtop ent framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",