@gqlbase/plugins 0.0.5 → 0.0.7

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 (86) hide show
  1. package/README.md +25 -0
  2. package/dist/base/InterfaceUtilsPlugin/InterfaceUtilsPlugin.d.ts +55 -0
  3. package/dist/base/InterfaceUtilsPlugin/InterfaceUtilsPlugin.d.ts.map +1 -0
  4. package/dist/base/InterfaceUtilsPlugin/InterfaceUtilsPlugin.js +100 -0
  5. package/dist/base/InterfaceUtilsPlugin/InterfaceUtilsPlugin.js.map +1 -0
  6. package/dist/base/InterfaceUtilsPlugin/InterfaceUtilsPlugin.utils.d.ts +3 -0
  7. package/dist/base/InterfaceUtilsPlugin/InterfaceUtilsPlugin.utils.d.ts.map +1 -0
  8. package/dist/base/InterfaceUtilsPlugin/InterfaceUtilsPlugin.utils.js +4 -0
  9. package/dist/base/InterfaceUtilsPlugin/InterfaceUtilsPlugin.utils.js.map +1 -0
  10. package/dist/base/InterfaceUtilsPlugin/index.d.ts +3 -0
  11. package/dist/base/InterfaceUtilsPlugin/index.d.ts.map +1 -0
  12. package/dist/base/InterfaceUtilsPlugin/index.js +3 -0
  13. package/dist/base/InterfaceUtilsPlugin/index.js.map +1 -0
  14. package/dist/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.d.ts +9 -3
  15. package/dist/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.d.ts.map +1 -1
  16. package/dist/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.js +26 -16
  17. package/dist/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.js.map +1 -1
  18. package/dist/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.utils.d.ts +19 -9
  19. package/dist/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.utils.d.ts.map +1 -1
  20. package/dist/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.utils.js +11 -11
  21. package/dist/base/ModelTypesGeneratorPlugin/ModelTypesGeneratorPlugin.utils.js.map +1 -1
  22. package/dist/base/RelationsPlugin/RelationsPlugin.d.ts +13 -8
  23. package/dist/base/RelationsPlugin/RelationsPlugin.d.ts.map +1 -1
  24. package/dist/base/RelationsPlugin/RelationsPlugin.js +30 -46
  25. package/dist/base/RelationsPlugin/RelationsPlugin.js.map +1 -1
  26. package/dist/base/RelationsPlugin/RelationsPlugin.utils.d.ts +5 -3
  27. package/dist/base/RelationsPlugin/RelationsPlugin.utils.d.ts.map +1 -1
  28. package/dist/base/RelationsPlugin/RelationsPlugin.utils.js +26 -1
  29. package/dist/base/RelationsPlugin/RelationsPlugin.utils.js.map +1 -1
  30. package/dist/base/RelationsPlugin/index.d.ts +1 -1
  31. package/dist/base/RelationsPlugin/index.d.ts.map +1 -1
  32. package/dist/base/RelationsPlugin/index.js +1 -1
  33. package/dist/base/RelationsPlugin/index.js.map +1 -1
  34. package/dist/base/RfcFeaturesPlugin/RfcFeaturesPlugin.d.ts +28 -0
  35. package/dist/base/RfcFeaturesPlugin/RfcFeaturesPlugin.d.ts.map +1 -0
  36. package/dist/base/RfcFeaturesPlugin/RfcFeaturesPlugin.js +33 -0
  37. package/dist/base/RfcFeaturesPlugin/RfcFeaturesPlugin.js.map +1 -0
  38. package/dist/base/RfcFeaturesPlugin/RfcFeaturesPlugin.utils.d.ts +14 -0
  39. package/dist/base/RfcFeaturesPlugin/RfcFeaturesPlugin.utils.d.ts.map +1 -0
  40. package/dist/base/RfcFeaturesPlugin/RfcFeaturesPlugin.utils.js +39 -0
  41. package/dist/base/RfcFeaturesPlugin/RfcFeaturesPlugin.utils.js.map +1 -0
  42. package/dist/base/RfcFeaturesPlugin/index.d.ts +3 -0
  43. package/dist/base/RfcFeaturesPlugin/index.d.ts.map +1 -0
  44. package/dist/base/RfcFeaturesPlugin/index.js +3 -0
  45. package/dist/base/RfcFeaturesPlugin/index.js.map +1 -0
  46. package/dist/base/basePreset.d.ts +2 -0
  47. package/dist/base/basePreset.d.ts.map +1 -1
  48. package/dist/base/basePreset.js +6 -0
  49. package/dist/base/basePreset.js.map +1 -1
  50. package/dist/base/index.d.ts +2 -0
  51. package/dist/base/index.d.ts.map +1 -1
  52. package/dist/base/index.js +2 -0
  53. package/dist/base/index.js.map +1 -1
  54. package/dist/relay/ConnectionPlugin/ConnectionPlugin.d.ts +63 -0
  55. package/dist/relay/ConnectionPlugin/ConnectionPlugin.d.ts.map +1 -0
  56. package/dist/relay/ConnectionPlugin/ConnectionPlugin.js +156 -0
  57. package/dist/relay/ConnectionPlugin/ConnectionPlugin.js.map +1 -0
  58. package/dist/relay/ConnectionPlugin/ConnectionPlugin.utils.d.ts +4 -0
  59. package/dist/relay/ConnectionPlugin/ConnectionPlugin.utils.d.ts.map +1 -0
  60. package/dist/relay/ConnectionPlugin/ConnectionPlugin.utils.js +26 -0
  61. package/dist/relay/ConnectionPlugin/ConnectionPlugin.utils.js.map +1 -0
  62. package/dist/relay/ConnectionPlugin/index.d.ts +3 -0
  63. package/dist/relay/ConnectionPlugin/index.d.ts.map +1 -0
  64. package/dist/relay/ConnectionPlugin/index.js +3 -0
  65. package/dist/relay/ConnectionPlugin/index.js.map +1 -0
  66. package/dist/relay/{NodeInterfacePlugin.d.ts → NodeInterfacePlugin/NodeInterfacePlugin.d.ts} +30 -6
  67. package/dist/relay/NodeInterfacePlugin/NodeInterfacePlugin.d.ts.map +1 -0
  68. package/dist/relay/{NodeInterfacePlugin.js → NodeInterfacePlugin/NodeInterfacePlugin.js} +37 -27
  69. package/dist/relay/NodeInterfacePlugin/NodeInterfacePlugin.js.map +1 -0
  70. package/dist/relay/NodeInterfacePlugin/index.d.ts +2 -0
  71. package/dist/relay/NodeInterfacePlugin/index.d.ts.map +1 -0
  72. package/dist/relay/NodeInterfacePlugin/index.js +2 -0
  73. package/dist/relay/NodeInterfacePlugin/index.js.map +1 -0
  74. package/dist/relay/index.d.ts +3 -2
  75. package/dist/relay/index.d.ts.map +1 -1
  76. package/dist/relay/index.js +3 -2
  77. package/dist/relay/index.js.map +1 -1
  78. package/dist/relay/relayPreset.js +2 -2
  79. package/dist/relay/relayPreset.js.map +1 -1
  80. package/package.json +3 -3
  81. package/dist/relay/ConnectionPlugin.d.ts +0 -46
  82. package/dist/relay/ConnectionPlugin.d.ts.map +0 -1
  83. package/dist/relay/ConnectionPlugin.js +0 -200
  84. package/dist/relay/ConnectionPlugin.js.map +0 -1
  85. package/dist/relay/NodeInterfacePlugin.d.ts.map +0 -1
  86. package/dist/relay/NodeInterfacePlugin.js.map +0 -1
@@ -1,16 +1,24 @@
1
1
  import { createPluginFactory } from "@gqlbase/core";
2
2
  import { DirectiveDefinitionNode, FieldNode, InputValueNode, InterfaceNode, ListTypeNode, NamedTypeNode, ObjectNode, UnionNode, } from "@gqlbase/core/definition";
3
3
  import { TransformerPluginExecutionError } from "@gqlbase/shared/errors";
4
- import { camelCase, pascalCase } from "@gqlbase/shared/format";
5
- import { isConnectionNode, isManyRelationship, isOneRelationship, isRelationField, isValidRelationTarget, RelationDirective, } from "./RelationsPlugin.utils.js";
4
+ import { pascalCase } from "@gqlbase/shared/format";
5
+ import { isPaginationConnection, isManyRelationship, isOneRelationship, isRelationField, isValidRelationTarget, parseFieldRelation, RelationDirective, } from "./RelationsPlugin.utils.js";
6
6
  import { isListTypeNode } from "../ModelPlugin/ModelPlugin.utils.js";
7
7
  /**
8
- * This plugin is responsible for adding the `@hasOne` and `@hasMany` directives to the schema, which can be used to define relationships between types. It also adds the necessary fields and arguments to the schema to support these directives.
8
+ * This plugin is responsible for adding the `@hasOne` and `@hasMany` directives to the schema, which can be used to define relationships between types.
9
9
  *
10
- * @example
10
+ * It also adds the necessary fields and arguments to the schema to support these directives.
11
11
  *
12
+ * @definition
12
13
  * ```graphql
14
+ * directive `@hasOne(key: String)` on FIELD_DEFINITION
15
+ *
16
+ * directive `@hasMany(key: String)` on FIELD_DEFINITION
17
+ *
18
+ * ```
13
19
  *
20
+ * @example
21
+ * ```graphql
14
22
  * # Before
15
23
  * type User {
16
24
  * id: ID!
@@ -28,64 +36,40 @@ import { isListTypeNode } from "../ModelPlugin/ModelPlugin.utils.js";
28
36
  * type User {
29
37
  * id: ID!
30
38
  * name: String!
31
- * posts: [Post]
39
+ * posts: [Post] # formatted by the plugin
32
40
  * }
33
41
  *
34
42
  * type Post {
35
43
  * id: ID!
36
44
  * title: String!
37
- * authorId: ID
45
+ * authorId: ID # added by the plugin
38
46
  * author: User
39
47
  * }
40
48
  * ```
41
- *
42
- * In the above example, the `User` type has a `posts` field that is decorated with the `@hasMany` directive, indicating that a user can have many posts. The plugin will automatically add the necessary fields and arguments to support this relationship in the schema.
43
- *
44
49
  */
45
50
  export class RelationsPlugin {
46
51
  name = "RelationsPlugin";
47
52
  context;
48
- _useConnections;
49
- constructor(context, options = { useConnections: false }) {
53
+ options;
54
+ constructor(context, options = {}) {
50
55
  this.context = context;
51
- this._useConnections = options.useConnections ?? false;
56
+ this.options = {
57
+ usePaginationTypes: options.usePaginationTypes ?? false,
58
+ };
52
59
  }
53
- _getRelationshipTarget(field) {
54
- const fieldType = this.context.document.getNode(field.type.getTypeName());
55
- if (isRelationField(field)) {
56
- return fieldType;
60
+ _getRelationshipTarget(object, field) {
61
+ const target = this.context.document.getNode(field.type.getTypeName());
62
+ if (!target || !isValidRelationTarget(target)) {
63
+ throw new TransformerPluginExecutionError(this.name, `Type ${target?.name ?? "unknwon type"} is not a valid relationship target for ${object.name}.${field.name}`);
57
64
  }
58
- return undefined;
65
+ return target;
59
66
  }
60
67
  _getFieldRelation(object, field) {
61
- const target = this._getRelationshipTarget(field);
62
- if (!target)
68
+ if (!isRelationField(field)) {
63
69
  return null;
64
- if (!isValidRelationTarget(target)) {
65
- throw new TransformerPluginExecutionError(this.name, `Type ${target.name} is not a valid relationship target for ${object.name}.${field.name}`);
66
- }
67
- let directive = field.getDirective(RelationDirective.HAS_ONE);
68
- if (directive) {
69
- if (field.hasDirective(RelationDirective.HAS_MANY)) {
70
- throw new TransformerPluginExecutionError(this.name, `Multiple relationship directives detected for ${object.name}.${field.name}`);
71
- }
72
- const args = directive.getArgumentsJSON();
73
- return {
74
- type: "oneToOne",
75
- target: target,
76
- key: args.key ?? camelCase(field.name, "id"),
77
- };
78
- }
79
- directive = field.getDirective(RelationDirective.HAS_MANY);
80
- if (directive) {
81
- const args = directive.getArgumentsJSON();
82
- return {
83
- type: "oneToMany",
84
- target: target,
85
- key: args.key ?? camelCase(object.name, "id"),
86
- };
87
70
  }
88
- throw new TransformerPluginExecutionError(this.name, `Could not find connection directive: ${field.name}`);
71
+ const target = this._getRelationshipTarget(object, field);
72
+ return parseFieldRelation(object, field, target);
89
73
  }
90
74
  _setRelationKey(node, key) {
91
75
  if (!node.hasField(key)) {
@@ -102,7 +86,7 @@ export class RelationsPlugin {
102
86
  }
103
87
  _createFieldConnection(field, target) {
104
88
  this._setConnectionArguments(field);
105
- if (isConnectionNode(target)) {
89
+ if (isPaginationConnection(target)) {
106
90
  return target;
107
91
  }
108
92
  const connectionTypeName = pascalCase(target.name, "Connection");
@@ -119,7 +103,7 @@ export class RelationsPlugin {
119
103
  if (definition instanceof InterfaceNode || definition instanceof ObjectNode) {
120
104
  if (definition.name === "Mutation")
121
105
  return false;
122
- if (isConnectionNode(definition))
106
+ if (isPaginationConnection(definition))
123
107
  return false;
124
108
  if (!definition.fields?.length)
125
109
  return false;
@@ -158,7 +142,7 @@ export class RelationsPlugin {
158
142
  if (!relation || relation.type === "oneToOne") {
159
143
  continue;
160
144
  }
161
- if (this._useConnections) {
145
+ if (this.options.usePaginationTypes) {
162
146
  const connection = this._createFieldConnection(field, relation.target);
163
147
  field.setType(NamedTypeNode.create(connection.name));
164
148
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"RelationsPlugin.js","sourceRoot":"","sources":["../../../src/base/RelationsPlugin/RelationsPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAA2C,MAAM,eAAe,CAAC;AAC7F,OAA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ACrD,SAAS;YACX,CAAC;YAED,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBAChC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;IAEM,OAAO,CAAC,UAAsC;QACnD,KAAK,MAAM,KAAK,IAAI,UAAU,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YAC5C,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7B,KAAK,CAAC,eAAe,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;YACnD,CAAC;YAED,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9B,KAAK,CAAC,eAAe,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,QAAQ;aAClB,UAAU,CAAC,iBAAiB,CAAC,OAAO,CAAC;aACrC,UAAU,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAC,eAAe,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { DefinitionNode, FieldNode, InterfaceNode, ObjectNode, UnionNode } from "@gqlbase/core/definition";
2
2
  export interface RelationPluginOptions {
3
- useConnections?: boolean;
3
+ usePaginationTypes?: boolean;
4
4
  }
5
5
  export declare const RelationDirective: {
6
6
  readonly HAS_ONE: "hasOne";
@@ -11,9 +11,11 @@ export interface FieldRelationship {
11
11
  target: ObjectNode | InterfaceNode | UnionNode;
12
12
  key?: string;
13
13
  }
14
+ export type RelationTarget = ObjectNode | InterfaceNode | UnionNode;
14
15
  export declare const isOneRelationship: (field: FieldNode) => boolean;
15
16
  export declare const isManyRelationship: (field: FieldNode) => boolean;
16
17
  export declare const isRelationField: (field: FieldNode) => boolean;
17
- export declare const isConnectionNode: (node: DefinitionNode) => boolean;
18
- export declare const isValidRelationTarget: (node: DefinitionNode) => node is ObjectNode | InterfaceNode | UnionNode;
18
+ export declare const isPaginationConnection: (node: DefinitionNode) => boolean;
19
+ export declare const isValidRelationTarget: (node: DefinitionNode) => node is RelationTarget;
20
+ export declare const parseFieldRelation: (object: ObjectNode | InterfaceNode, field: FieldNode, target: RelationTarget) => Required<FieldRelationship> | null;
19
21
  //# sourceMappingURL=RelationsPlugin.utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RelationsPlugin.utils.d.ts","sourceRoot":"","sources":["../../../src/base/RelationsPlugin/RelationsPlugin.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,SAAS,EACT,aAAa,EACb,UAAU,EACV,SAAS,EACV,MAAM,0BAA0B,CAAC;AAElC,MAAM,WAAW,qBAAqB;IACpC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,eAAO,MAAM,iBAAiB;;;CAGpB,CAAC;AAEX,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,UAAU,GAAG,WAAW,CAAC;IAC/B,MAAM,EAAE,UAAU,GAAG,aAAa,GAAG,SAAS,CAAC;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,iBAAiB,GAAI,OAAO,SAAS,KAAG,OAEpD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,OAAO,SAAS,KAAG,OAErD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,SAAS,KAAG,OAElD,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,MAAM,cAAc,KAAG,OASvD,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,MAAM,cAAc,KACnB,IAAI,IAAI,UAAU,GAAG,aAAa,GAAG,SAEvC,CAAC"}
1
+ {"version":3,"file":"RelationsPlugin.utils.d.ts","sourceRoot":"","sources":["../../../src/base/RelationsPlugin/RelationsPlugin.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,SAAS,EACT,aAAa,EACb,UAAU,EACV,SAAS,EACV,MAAM,0BAA0B,CAAC;AAGlC,MAAM,WAAW,qBAAqB;IACpC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,eAAO,MAAM,iBAAiB;;;CAGpB,CAAC;AAEX,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,UAAU,GAAG,WAAW,CAAC;IAC/B,MAAM,EAAE,UAAU,GAAG,aAAa,GAAG,SAAS,CAAC;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,aAAa,GAAG,SAAS,CAAC;AAEpE,eAAO,MAAM,iBAAiB,GAAI,OAAO,SAAS,KAAG,OAEpD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,OAAO,SAAS,KAAG,OAErD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,SAAS,KAAG,OAElD,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,MAAM,cAAc,KAAG,OAS7D,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,MAAM,cAAc,KAAG,IAAI,IAAI,cAEpE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,UAAU,GAAG,aAAa,EAClC,OAAO,SAAS,EAChB,QAAQ,cAAc,KACrB,QAAQ,CAAC,iBAAiB,CAAC,GAAG,IA4BhC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { InterfaceNode, ObjectNode, UnionNode, } from "@gqlbase/core/definition";
2
+ import { camelCase } from "@gqlbase/shared/format";
2
3
  export const RelationDirective = {
3
4
  HAS_ONE: "hasOne",
4
5
  HAS_MANY: "hasMany",
@@ -12,7 +13,7 @@ export const isManyRelationship = (field) => {
12
13
  export const isRelationField = (field) => {
13
14
  return isOneRelationship(field) || isManyRelationship(field);
14
15
  };
15
- export const isConnectionNode = (node) => {
16
+ export const isPaginationConnection = (node) => {
16
17
  if (node instanceof ObjectNode) {
17
18
  if (!node.name.endsWith("Connection"))
18
19
  return false;
@@ -27,4 +28,28 @@ export const isConnectionNode = (node) => {
27
28
  export const isValidRelationTarget = (node) => {
28
29
  return node instanceof ObjectNode || node instanceof InterfaceNode || node instanceof UnionNode;
29
30
  };
31
+ export const parseFieldRelation = (object, field, target) => {
32
+ if (isOneRelationship(field) && isManyRelationship(field)) {
33
+ throw new Error(`Multiple relationship directives detected for field: ${field.name}`);
34
+ }
35
+ if (isOneRelationship(field)) {
36
+ const directive = field.getDirective(RelationDirective.HAS_ONE);
37
+ const args = directive?.getArgumentsJSON();
38
+ return {
39
+ type: "oneToOne",
40
+ target: target,
41
+ key: args?.key ?? camelCase(field.name, "id"),
42
+ };
43
+ }
44
+ if (isManyRelationship(field)) {
45
+ const directive = field.getDirective(RelationDirective.HAS_MANY);
46
+ const args = directive?.getArgumentsJSON();
47
+ return {
48
+ type: "oneToMany",
49
+ target: target,
50
+ key: args?.key ?? camelCase(object.name, "id"),
51
+ };
52
+ }
53
+ return null;
54
+ };
30
55
  //# sourceMappingURL=RelationsPlugin.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RelationsPlugin.utils.js","sourceRoot":"","sources":["../../../src/base/RelationsPlugin/RelationsPlugin.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACb,UAAU,EACV,SAAS,GACV,MAAM,0BAA0B,CAAC;AAMlC,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,SAAS;CACX,CAAC;AAQX,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAgB,EAAW,EAAE;IAC7D,OAAO,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM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B,GAAG,CAChC,MAAkC,EAClC,KAAgB,EAChB,MAAsB,EACc,EAAE;IACtC,IAAI,iBAAiB,CAAC,KAAK,CAAC,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,wDAAwD,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACxF,CAAC;IAED,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAChE,MAAM,IAAI,GAAG,SAAS,EAAE,gBAAgB,EAAmB,CAAC;QAE5D,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,IAAI,EAAE,GAAG,IAAI,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;SAC9C,CAAC;IACJ,CAAC;IAED,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QACjE,MAAM,IAAI,GAAG,SAAS,EAAE,gBAAgB,EAAmB,CAAC;QAE5D,OAAO;YACL,IAAI,EAAE,WAAW;YACjB,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,IAAI,EAAE,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC;SAC/C,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -1,3 +1,3 @@
1
1
  export { RelationsPlugin, relationPlugin } from "./RelationsPlugin.js";
2
- export { type RelationPluginOptions, type FieldRelationship, RelationDirective, isConnectionNode, isManyRelationship, isOneRelationship, isRelationField, isValidRelationTarget, } from "./RelationsPlugin.utils.js";
2
+ export { RelationDirective, isPaginationConnection, isManyRelationship, isOneRelationship, isRelationField, isValidRelationTarget, parseFieldRelation, type RelationPluginOptions, type FieldRelationship, type RelationTarget, } from "./RelationsPlugin.utils.js";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/base/RelationsPlugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,GACtB,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/base/RelationsPlugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,cAAc,GACpB,MAAM,4BAA4B,CAAC"}
@@ -1,3 +1,3 @@
1
1
  export { RelationsPlugin, relationPlugin } from "./RelationsPlugin.js";
2
- export { RelationDirective, isConnectionNode, isManyRelationship, isOneRelationship, isRelationField, isValidRelationTarget, } from "./RelationsPlugin.utils.js";
2
+ export { RelationDirective, isPaginationConnection, isManyRelationship, isOneRelationship, isRelationField, isValidRelationTarget, parseFieldRelation, } from "./RelationsPlugin.utils.js";
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/base/RelationsPlugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAGL,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,GACtB,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/base/RelationsPlugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,GAInB,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { ITransformerContext, TransformerPluginBase } from "@gqlbase/core";
2
+ /**
3
+ * Adds support for features that are in RFC status or draft mode.
4
+ *
5
+ * @see https://github.com/graphql/graphql-wg
6
+ *
7
+ * @definition
8
+ * ```graphql
9
+ * directive `@semanticNonNull(levels: [Int!]! = [0])` on FIELD_DEFINITION
10
+ * ```
11
+ *
12
+ * @example
13
+ * ```graphql
14
+ * type User {
15
+ * id: ID!
16
+ * name: String `@semanticNonNull`
17
+ * tags: [String] `@semanticNonNull(levels: [0, 1])`
18
+ * }
19
+ * ```
20
+ *
21
+ * In the above example, the `name` field is decorated with the `@semanticNonNull` directive, indicating that it is semantically non-nullable. The plugin will use this information to enforce non-nullability at runtime, even if the field is not marked as non-nullable in the schema.
22
+ */
23
+ export declare class RfcFeaturesPlugin extends TransformerPluginBase {
24
+ constructor(context: ITransformerContext);
25
+ init(): void;
26
+ }
27
+ export declare const rfcFeaturesPlugin: (options?: unknown) => import("@gqlbase/core").IPluginFactory;
28
+ //# sourceMappingURL=RfcFeaturesPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RfcFeaturesPlugin.d.ts","sourceRoot":"","sources":["../../../src/base/RfcFeaturesPlugin/RfcFeaturesPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAUhG;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,qBAAa,iBAAkB,SAAQ,qBAAqB;gBAC9C,OAAO,EAAE,mBAAmB;IAIjC,IAAI;CAeZ;AAED,eAAO,MAAM,iBAAiB,+DAAyC,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { createPluginFactory, TransformerPluginBase } from "@gqlbase/core";
2
+ import { DirectiveDefinitionNode, InputValueNode, ListTypeNode, NamedTypeNode, NonNullTypeNode, ValueNode, } from "@gqlbase/core/definition";
3
+ /**
4
+ * Adds support for features that are in RFC status or draft mode.
5
+ *
6
+ * @see https://github.com/graphql/graphql-wg
7
+ *
8
+ * @definition
9
+ * ```graphql
10
+ * directive `@semanticNonNull(levels: [Int!]! = [0])` on FIELD_DEFINITION
11
+ * ```
12
+ *
13
+ * @example
14
+ * ```graphql
15
+ * type User {
16
+ * id: ID!
17
+ * name: String `@semanticNonNull`
18
+ * tags: [String] `@semanticNonNull(levels: [0, 1])`
19
+ * }
20
+ * ```
21
+ *
22
+ * In the above example, the `name` field is decorated with the `@semanticNonNull` directive, indicating that it is semantically non-nullable. The plugin will use this information to enforce non-nullability at runtime, even if the field is not marked as non-nullable in the schema.
23
+ */
24
+ export class RfcFeaturesPlugin extends TransformerPluginBase {
25
+ constructor(context) {
26
+ super("RfcFeaturesPlugin", context);
27
+ }
28
+ init() {
29
+ this.context.base.addNode(DirectiveDefinitionNode.create("semanticNonNull", ["FIELD_DEFINITION"], InputValueNode.create("levels", NonNullTypeNode.create(ListTypeNode.create(NonNullTypeNode.create(NamedTypeNode.create("Int")))), ValueNode.list([ValueNode.int(0)]))));
30
+ }
31
+ }
32
+ export const rfcFeaturesPlugin = createPluginFactory(RfcFeaturesPlugin);
33
+ //# sourceMappingURL=RfcFeaturesPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RfcFeaturesPlugin.js","sourceRoot":"","sources":["../../../src/base/RfcFeaturesPlugin/RfcFeaturesPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAuB,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAChG,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,eAAe,EACf,SAAS,GACV,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,OAAO,iBAAkB,SAAQ,qBAAqB;IAC1D,YAAY,OAA4B;QACtC,KAAK,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IAEM,IAAI;QACT,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CACvB,uBAAuB,CAAC,MAAM,CAC5B,iBAAiB,EACjB,CAAC,kBAAkB,CAAC,EACpB,cAAc,CAAC,MAAM,CACnB,QAAQ,EACR,eAAe,CAAC,MAAM,CACpB,YAAY,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CACzE,EACD,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CACnC,CACF,CACF,CAAC;IACJ,CAAC;CACF;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { FieldNode } from "@gqlbase/core/definition";
2
+ export declare const RfcDirective: {
3
+ readonly SEMANTIC_NON_NULL: "semanticNonNull";
4
+ };
5
+ /**
6
+ * Determines if a field is semantically nullable based on its type and/or the presence of the `@semanticNonNull` directive.
7
+ *
8
+ * @param field Fiel node to check
9
+ * @param level Semantic nullability level
10
+ *
11
+ * @returns `false` if the field is non-nullable either by being a NonNullType or by having the `@semanticNonNull` directive at the specified level, `true` otherwise.
12
+ */
13
+ export declare const isSemanticNullable: (field: FieldNode, level?: number) => boolean;
14
+ //# sourceMappingURL=RfcFeaturesPlugin.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RfcFeaturesPlugin.utils.d.ts","sourceRoot":"","sources":["../../../src/base/RfcFeaturesPlugin/RfcFeaturesPlugin.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA2C,MAAM,0BAA0B,CAAC;AAE9F,eAAO,MAAM,YAAY;;CAEf,CAAC;AAgBX;;;;;;;GAOG;AAEH,eAAO,MAAM,kBAAkB,GAAI,OAAO,SAAS,EAAE,cAAS,YAe7D,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { ListTypeNode, NonNullTypeNode } from "@gqlbase/core/definition";
2
+ export const RfcDirective = {
3
+ SEMANTIC_NON_NULL: "semanticNonNull",
4
+ };
5
+ /**
6
+ * Unwraps a type to the given depth level.
7
+ * Only `ListTypeNode` counts as a level — `NonNullTypeNode` is
8
+ * a modifier at the same depth and is skipped transparently.
9
+ */
10
+ const getTypeAtLevel = (type, level) => {
11
+ if (level <= 0)
12
+ return type;
13
+ if (type instanceof NonNullTypeNode)
14
+ return getTypeAtLevel(type.type, level);
15
+ if (type instanceof ListTypeNode)
16
+ return getTypeAtLevel(type.type, level - 1);
17
+ return type;
18
+ };
19
+ /**
20
+ * Determines if a field is semantically nullable based on its type and/or the presence of the `@semanticNonNull` directive.
21
+ *
22
+ * @param field Fiel node to check
23
+ * @param level Semantic nullability level
24
+ *
25
+ * @returns `false` if the field is non-nullable either by being a NonNullType or by having the `@semanticNonNull` directive at the specified level, `true` otherwise.
26
+ */
27
+ export const isSemanticNullable = (field, level = 0) => {
28
+ const typeAtLevel = getTypeAtLevel(field.type, level);
29
+ if (typeAtLevel instanceof NonNullTypeNode) {
30
+ return false;
31
+ }
32
+ if (field.hasDirective(RfcDirective.SEMANTIC_NON_NULL)) {
33
+ const directive = field.getDirective(RfcDirective.SEMANTIC_NON_NULL);
34
+ const { levels = [0] } = directive?.getArgumentsJSON() ?? {};
35
+ return !levels?.includes(level);
36
+ }
37
+ return true;
38
+ };
39
+ //# sourceMapp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EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { RfcFeaturesPlugin, rfcFeaturesPlugin } from "./RfcFeaturesPlugin.js";
2
+ export { RfcDirective, isSemanticNullable } from "./RfcFeaturesPlugin.utils.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/base/RfcFeaturesPlugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { RfcFeaturesPlugin, rfcFeaturesPlugin } from "./RfcFeaturesPlugin.js";
2
+ export { RfcDirective, isSemanticNullable } from "./RfcFeaturesPlugin.utils.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/base/RfcFeaturesPlugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC"}
@@ -3,9 +3,11 @@
3
3
  *
4
4
  * Inludes:
5
5
  * - `UtilitiesPlugin`
6
+ * - `InterfaceUtilsPlugin`
6
7
  * - `ScalarsPlugin`
7
8
  * - `ModelPlugin`
8
9
  * - `RelationsPlugin`
10
+ * - `RfcFeaturesPlugin`
9
11
  * - `SchemaGeneratorPlugin`
10
12
  * - `ModelTypesGeneratorPlugin`
11
13
  *
@@ -1 +1 @@
1
- {"version":3,"file":"basePreset.d.ts","sourceRoot":"","sources":["../../src/base/basePreset.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;GAYG;AAEH,wBAAgB,UAAU,6CASzB"}
1
+ {"version":3,"file":"basePreset.d.ts","sourceRoot":"","sources":["../../src/base/basePreset.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;GAcG;AAEH,wBAAgB,UAAU,6CAWzB"}
@@ -1,7 +1,9 @@
1
1
  import { utilsPlugin } from "./UtilitiesPlugin/index.js";
2
+ import { interfaceUtilsPlugin } from "./InterfaceUtilsPlugin/index.js";
2
3
  import { scalarsPlugin } from "./ScalarsPlugin/index.js";
3
4
  import { modelPlugin } from "./ModelPlugin/index.js";
4
5
  import { relationPlugin } from "./RelationsPlugin/index.js";
6
+ import { rfcFeaturesPlugin } from "./RfcFeaturesPlugin/index.js";
5
7
  import { schemaGeneratorPlugin } from "./SchemaGeneratorPlugin.js";
6
8
  import { modelTypesGeneratorPlugin } from "./ModelTypesGeneratorPlugin/index.js";
7
9
  /**
@@ -9,9 +11,11 @@ import { modelTypesGeneratorPlugin } from "./ModelTypesGeneratorPlugin/index.js"
9
11
  *
10
12
  * Inludes:
11
13
  * - `UtilitiesPlugin`
14
+ * - `InterfaceUtilsPlugin`
12
15
  * - `ScalarsPlugin`
13
16
  * - `ModelPlugin`
14
17
  * - `RelationsPlugin`
18
+ * - `RfcFeaturesPlugin`
15
19
  * - `SchemaGeneratorPlugin`
16
20
  * - `ModelTypesGeneratorPlugin`
17
21
  *
@@ -20,9 +24,11 @@ import { modelTypesGeneratorPlugin } from "./ModelTypesGeneratorPlugin/index.js"
20
24
  export function basePreset() {
21
25
  return [
22
26
  utilsPlugin(),
27
+ interfaceUtilsPlugin(),
23
28
  scalarsPlugin(),
24
29
  modelPlugin(),
25
30
  relationPlugin(),
31
+ rfcFeaturesPlugin(),
26
32
  schemaGeneratorPlugin(),
27
33
  modelTypesGeneratorPlugin(),
28
34
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"basePreset.js","sourceRoot":"","sources":["../../src/base/basePreset.ts"],"names":[],"mappings":"AAAA,OAAO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,6 +1,8 @@
1
1
  export { ModelPlugin, type ModelPluginOptions, ModelDirective, ModelOperation, modelPlugin, isModel, } from "./ModelPlugin/index.js";
2
2
  export { RelationsPlugin, relationPlugin, RelationDirective, isRelationField, isOneRelationship, isManyRelationship, type FieldRelationship, type RelationPluginOptions, } from "./RelationsPlugin/index.js";
3
3
  export { UtilitiesPlugin, UtilityDirective, utilsPlugin, isReadOnly, isClientOnly, isCreateOnly, isFilterOnly, isServerOnly, isUpdateOnly, isWriteOnly, } from "./UtilitiesPlugin/index.js";
4
+ export { RfcFeaturesPlugin, RfcDirective, rfcFeaturesPlugin, isSemanticNullable, } from "./RfcFeaturesPlugin/index.js";
5
+ export { ScalarsPlugin, scalarsPlugin } from "./ScalarsPlugin/index.js";
4
6
  export { SchemaGeneratorPlugin, schemaGeneratorPlugin } from "./SchemaGeneratorPlugin.js";
5
7
  export { ModelTypesGeneratorPlugin, modelTypesGeneratorPlugin, } from "./ModelTypesGeneratorPlugin/index.js";
6
8
  export { basePreset } from "./basePreset.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,kBAAkB,EACvB,cAAc,EACd,cAAc,EACd,WAAW,EACX,OAAO,GACR,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,GACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,kBAAkB,EACvB,cAAc,EACd,cAAc,EACd,WAAW,EACX,OAAO,GACR,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,GACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,6 +1,8 @@
1
1
  export { ModelPlugin, ModelDirective, ModelOperation, modelPlugin, isModel, } from "./ModelPlugin/index.js";
2
2
  export { RelationsPlugin, relationPlugin, RelationDirective, isRelationField, isOneRelationship, isManyRelationship, } from "./RelationsPlugin/index.js";
3
3
  export { UtilitiesPlugin, UtilityDirective, utilsPlugin, isReadOnly, isClientOnly, isCreateOnly, isFilterOnly, isServerOnly, isUpdateOnly, isWriteOnly, } from "./UtilitiesPlugin/index.js";
4
+ export { RfcFeaturesPlugin, RfcDirective, rfcFeaturesPlugin, isSemanticNullable, } from "./RfcFeaturesPlugin/index.js";
5
+ export { ScalarsPlugin, scalarsPlugin } from "./ScalarsPlugin/index.js";
4
6
  export { SchemaGeneratorPlugin, schemaGeneratorPlugin } from "./SchemaGeneratorPlugin.js";
5
7
  export { ModelTypesGeneratorPlugin, modelTypesGeneratorPlugin, } from "./ModelTypesGeneratorPlugin/index.js";
6
8
  export { basePreset } from "./basePreset.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,cAAc,EACd,cAAc,EACd,WAAW,EACX,OAAO,GACR,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GAGnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,GACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,cAAc,EACd,cAAc,EACd,WAAW,EACX,OAAO,GACR,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GAGnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,GACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,63 @@
1
+ import { ITransformerContext } from "@gqlbase/core/context";
2
+ import { TransformerPluginBase } from "@gqlbase/core/plugins";
3
+ import { DefinitionNode, InterfaceNode, ObjectNode } from "@gqlbase/core/definition";
4
+ /**
5
+ * Transforms many relationships into Relay compaticale connections, and adds the necessary fields and arguments to support cursor based pagination.
6
+ *
7
+ * @example
8
+ * ```graphql
9
+ * # Before
10
+ * type User {
11
+ * id: ID!
12
+ * name: String!
13
+ * posts: Post `@hasMany`
14
+ * }
15
+ *
16
+ * type Post {
17
+ * id: ID!
18
+ * title: String!
19
+ * }
20
+ *
21
+ * # After
22
+ * type User {
23
+ * id: ID!
24
+ * name: String!
25
+ * posts: PostConnection
26
+ * }
27
+ *
28
+ * type Post {
29
+ * id: ID!
30
+ * title: String!
31
+ * }
32
+ *
33
+ * type PostConnection {
34
+ * edges: [PostEdge]
35
+ * pageInfo: PageInfo!
36
+ * }
37
+ *
38
+ * type PostEdge {
39
+ * cursor: String
40
+ * node: Post
41
+ * }
42
+ *
43
+ * type PageInfo {
44
+ * hasNextPage: Boolean!
45
+ * hasPreviousPage: Boolean!
46
+ * startCursor: String
47
+ * endCursor: String
48
+ * }
49
+ *
50
+ * ```
51
+ */
52
+ export declare class ConnectionPlugin extends TransformerPluginBase {
53
+ constructor(context: ITransformerContext);
54
+ private _getConnectionTarget;
55
+ private _getFieldConnection;
56
+ private _setConnectionArguments;
57
+ private _createConnection;
58
+ before(): void;
59
+ match(definition: DefinitionNode): boolean;
60
+ execute(definition: ObjectNode | InterfaceNode): void;
61
+ }
62
+ export declare const connectionPlugin: (options?: unknown) => import("@gqlbase/core/plugins").IPluginFactory;
63
+ //# sourceMappingURL=ConnectionPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectionPlugin.d.ts","sourceRoot":"","sources":["../../../src/relay/ConnectionPlugin/ConnectionPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAuB,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EACL,cAAc,EAEd,aAAa,EACb,UAAU,EAQX,MAAM,0BAA0B,CAAC;AAalC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,qBAAa,gBAAiB,SAAQ,qBAAqB;gBAC7C,OAAO,EAAE,mBAAmB;IAIxC,OAAO,CAAC,oBAAoB;IAoB5B,OAAO,CAAC,mBAAmB;IAa3B,OAAO,CAAC,uBAAuB;IAU/B,OAAO,CAAC,iBAAiB;IAqDlB,MAAM,IAAI,IAAI;IAad,KAAK,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO;IAY1C,OAAO,CAAC,UAAU,EAAE,UAAU,GAAG,aAAa;CAatD;AAED,eAAO,MAAM,gBAAgB,uEAAwC,CAAC"}