@snowtop/ent 0.1.0-alpha131 → 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.
@@ -28,7 +28,7 @@ interface gqlFieldArg extends gqlFieldOptionsBase {
28
28
  isContextArg?: boolean;
29
29
  }
30
30
  export interface gqlFieldOptions extends gqlFieldOptionsBase {
31
- nodeName: string;
31
+ class: string;
32
32
  args?: gqlFieldArg[];
33
33
  async?: boolean;
34
34
  type: NonNullable<gqlFieldOptionsBase["type"]>;
@@ -331,7 +331,7 @@ class GQLCapture {
331
331
  });
332
332
  }
333
333
  return {
334
- nodeName: options.nodeName,
334
+ nodeName: options.class,
335
335
  gqlName: options?.name || ctx.name.toString(),
336
336
  functionName: ctx.name.toString(),
337
337
  args: args,
@@ -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
  }
@@ -59,11 +59,11 @@ let UserAuthInput = (() => {
59
59
  __setFunctionName(_classThis, "UserAuthInput");
60
60
  (() => {
61
61
  _emailAddress_decorators = [(0, graphql_1.gqlField)({
62
- nodeName: "UserAuthInput",
62
+ class: "UserAuthInput",
63
63
  type: graphql_2.GraphQLString,
64
64
  })];
65
65
  _password_decorators = [(0, graphql_1.gqlField)({
66
- nodeName: "UserAuthInput",
66
+ class: "UserAuthInput",
67
67
  type: graphql_2.GraphQLString,
68
68
  })];
69
69
  __esDecorate(null, null, _emailAddress_decorators, { kind: "field", name: "emailAddress", static: false, private: false, access: { has: obj => "emailAddress" in obj, get: obj => obj.emailAddress, set: (obj, value) => { obj.emailAddress = value; } } }, _emailAddress_initializers, _instanceExtraInitializers);
@@ -93,10 +93,10 @@ let UserAuthResponse = (() => {
93
93
  __setFunctionName(_classThis_1, "UserAuthResponse");
94
94
  (() => {
95
95
  _token_decorators = [(0, graphql_1.gqlField)({
96
- nodeName: "UserAuthResponse",
96
+ class: "UserAuthResponse",
97
97
  type: graphql_2.GraphQLString,
98
98
  })];
99
- _viewerID_decorators = [(0, graphql_1.gqlField)({ nodeName: "UserAuthResponses", type: graphql_2.GraphQLID })];
99
+ _viewerID_decorators = [(0, graphql_1.gqlField)({ class: "UserAuthResponses", type: graphql_2.GraphQLID })];
100
100
  __esDecorate(null, null, _token_decorators, { kind: "field", name: "token", static: false, private: false, access: { has: obj => "token" in obj, get: obj => obj.token, set: (obj, value) => { obj.token = value; } } }, _token_initializers, _instanceExtraInitializers_1);
101
101
  __esDecorate(null, null, _viewerID_decorators, { kind: "field", name: "viewerID", static: false, private: false, access: { has: obj => "viewerID" in obj, get: obj => obj.viewerID, set: (obj, value) => { obj.viewerID = value; } } }, _viewerID_initializers, _instanceExtraInitializers_1);
102
102
  __esDecorate(null, _classDescriptor_1 = { value: _classThis_1 }, _classDecorators_1, { kind: "class", name: _classThis_1.name }, null, _classExtraInitializers_1);
@@ -119,7 +119,7 @@ let AuthResolver = (() => {
119
119
  },
120
120
  (() => {
121
121
  _userAuth_decorators = [(0, graphql_1.gqlMutation)({
122
- nodeName: "AuthResolver",
122
+ class: "AuthResolver",
123
123
  name: "userAuth",
124
124
  type: UserAuthResponse,
125
125
  args: [
@@ -58,7 +58,7 @@ let ViewerType = (() => {
58
58
  __setFunctionName(_classThis, "ViewerType");
59
59
  (() => {
60
60
  _get_viewerID_decorators = [(0, graphql_1.gqlField)({
61
- nodeName: "ViewerType",
61
+ class: "ViewerType",
62
62
  type: graphql_2.GraphQLID,
63
63
  nullable: true,
64
64
  })];
@@ -83,7 +83,7 @@ exports.default = (() => {
83
83
  },
84
84
  (() => {
85
85
  _viewer_decorators = [(0, graphql_1.gqlQuery)({
86
- nodeName: "ViewerResolver",
86
+ class: "ViewerResolver",
87
87
  name: "viewer",
88
88
  type: ViewerType,
89
89
  args: [(0, graphql_1.gqlContextType)()],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowtop/ent",
3
- "version": "0.1.0-alpha131",
3
+ "version": "0.1.0-alpha133",
4
4
  "description": "snowtop ent framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",