@commitspark/graphql-api 2.0.0-beta.4 → 2.0.0-beta.5

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 (154) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +147 -80
  3. package/dist/cjs/graphql/errors.d.ts +3 -2
  4. package/dist/cjs/graphql/errors.d.ts.map +1 -1
  5. package/dist/cjs/graphql/errors.js +11 -1
  6. package/dist/cjs/graphql/errors.js.map +1 -1
  7. package/dist/cjs/graphql/input-type-generator.d.ts.map +1 -1
  8. package/dist/cjs/graphql/input-type-generator.js +5 -10
  9. package/dist/cjs/graphql/input-type-generator.js.map +1 -1
  10. package/dist/cjs/graphql/queries-mutations-generator.d.ts +5 -5
  11. package/dist/cjs/graphql/queries-mutations-generator.d.ts.map +1 -1
  12. package/dist/cjs/graphql/queries-mutations-generator.js +45 -7
  13. package/dist/cjs/graphql/queries-mutations-generator.js.map +1 -1
  14. package/dist/cjs/graphql/resolvers/commit-message.d.ts +11 -0
  15. package/dist/cjs/graphql/resolvers/commit-message.d.ts.map +1 -0
  16. package/dist/cjs/graphql/resolvers/commit-message.js +22 -0
  17. package/dist/cjs/graphql/resolvers/commit-message.js.map +1 -0
  18. package/dist/cjs/graphql/resolvers/field-resolvers/entry-reference-resolver.js +2 -2
  19. package/dist/cjs/graphql/resolvers/field-resolvers/entry-reference-resolver.js.map +1 -1
  20. package/dist/cjs/graphql/resolvers/field-resolvers/field-default-value-resolver.js +3 -3
  21. package/dist/cjs/graphql/resolvers/field-resolvers/field-default-value-resolver.js.map +1 -1
  22. package/dist/cjs/graphql/resolvers/field-resolvers/version-resolver.d.ts +3 -0
  23. package/dist/cjs/graphql/resolvers/field-resolvers/version-resolver.d.ts.map +1 -0
  24. package/dist/cjs/graphql/resolvers/field-resolvers/version-resolver.js +7 -0
  25. package/dist/cjs/graphql/resolvers/field-resolvers/version-resolver.js.map +1 -0
  26. package/dist/cjs/graphql/resolvers/object-type-field-default-value-resolver-generator.js +1 -1
  27. package/dist/cjs/graphql/resolvers/object-type-field-default-value-resolver-generator.js.map +1 -1
  28. package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-create-resolver.d.ts.map +1 -1
  29. package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-create-resolver.js +34 -28
  30. package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-create-resolver.js.map +1 -1
  31. package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-delete-resolver.d.ts.map +1 -1
  32. package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-delete-resolver.js +28 -23
  33. package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-delete-resolver.js.map +1 -1
  34. package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-update-resolver.d.ts.map +1 -1
  35. package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-update-resolver.js +25 -18
  36. package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-update-resolver.js.map +1 -1
  37. package/dist/cjs/graphql/resolvers/query-mutation-resolvers/query-search-resolver.js +5 -5
  38. package/dist/cjs/graphql/resolvers/query-mutation-resolvers/query-search-resolver.js.map +1 -1
  39. package/dist/cjs/graphql/resolvers/query-mutation-resolvers/union-type-resolver.js +1 -1
  40. package/dist/cjs/graphql/resolvers/query-mutation-resolvers/union-type-resolver.js.map +1 -1
  41. package/dist/cjs/graphql/resolvers/types.d.ts +9 -1
  42. package/dist/cjs/graphql/resolvers/types.d.ts.map +1 -1
  43. package/dist/cjs/graphql/schema-generator.d.ts.map +1 -1
  44. package/dist/cjs/graphql/schema-generator.js +9 -8
  45. package/dist/cjs/graphql/schema-generator.js.map +1 -1
  46. package/dist/cjs/graphql/schema-utils/entry-reference-util.js +7 -7
  47. package/dist/cjs/graphql/schema-utils/entry-reference-util.js.map +1 -1
  48. package/dist/cjs/graphql/schema-utils/union-type-util.js +2 -2
  49. package/dist/cjs/graphql/schema-utils/union-type-util.js.map +1 -1
  50. package/dist/cjs/graphql/schema-validator.d.ts.map +1 -1
  51. package/dist/cjs/graphql/schema-validator.js +16 -0
  52. package/dist/cjs/graphql/schema-validator.js.map +1 -1
  53. package/dist/cjs/index.js +3 -0
  54. package/dist/cjs/index.js.map +1 -1
  55. package/dist/cjs/persistence/cache.d.ts +3 -0
  56. package/dist/cjs/persistence/cache.d.ts.map +1 -1
  57. package/dist/cjs/persistence/cache.js +8 -17
  58. package/dist/cjs/persistence/cache.js.map +1 -1
  59. package/dist/cjs/persistence/commit-with-retry.d.ts +16 -0
  60. package/dist/cjs/persistence/commit-with-retry.d.ts.map +1 -0
  61. package/dist/cjs/persistence/commit-with-retry.js +39 -0
  62. package/dist/cjs/persistence/commit-with-retry.js.map +1 -0
  63. package/dist/cjs/persistence/git-adapter-call.d.ts +10 -0
  64. package/dist/cjs/persistence/git-adapter-call.d.ts.map +1 -0
  65. package/dist/cjs/persistence/git-adapter-call.js +29 -0
  66. package/dist/cjs/persistence/git-adapter-call.js.map +1 -0
  67. package/dist/cjs/persistence/persistence.d.ts +11 -0
  68. package/dist/cjs/persistence/persistence.d.ts.map +1 -1
  69. package/dist/cjs/persistence/persistence.js +37 -2
  70. package/dist/cjs/persistence/persistence.js.map +1 -1
  71. package/dist/esm/graphql/errors.d.ts +3 -2
  72. package/dist/esm/graphql/errors.d.ts.map +1 -1
  73. package/dist/esm/graphql/errors.js +10 -0
  74. package/dist/esm/graphql/errors.js.map +1 -1
  75. package/dist/esm/graphql/input-type-generator.d.ts.map +1 -1
  76. package/dist/esm/graphql/input-type-generator.js +6 -11
  77. package/dist/esm/graphql/input-type-generator.js.map +1 -1
  78. package/dist/esm/graphql/queries-mutations-generator.d.ts +5 -5
  79. package/dist/esm/graphql/queries-mutations-generator.d.ts.map +1 -1
  80. package/dist/esm/graphql/queries-mutations-generator.js +43 -6
  81. package/dist/esm/graphql/queries-mutations-generator.js.map +1 -1
  82. package/dist/esm/graphql/resolvers/commit-message.d.ts +11 -0
  83. package/dist/esm/graphql/resolvers/commit-message.d.ts.map +1 -0
  84. package/dist/esm/graphql/resolvers/commit-message.js +19 -0
  85. package/dist/esm/graphql/resolvers/commit-message.js.map +1 -0
  86. package/dist/esm/graphql/resolvers/field-resolvers/entry-reference-resolver.js +3 -3
  87. package/dist/esm/graphql/resolvers/field-resolvers/entry-reference-resolver.js.map +1 -1
  88. package/dist/esm/graphql/resolvers/field-resolvers/field-default-value-resolver.js +4 -4
  89. package/dist/esm/graphql/resolvers/field-resolvers/field-default-value-resolver.js.map +1 -1
  90. package/dist/esm/graphql/resolvers/field-resolvers/version-resolver.d.ts +3 -0
  91. package/dist/esm/graphql/resolvers/field-resolvers/version-resolver.d.ts.map +1 -0
  92. package/dist/esm/graphql/resolvers/field-resolvers/version-resolver.js +3 -0
  93. package/dist/esm/graphql/resolvers/field-resolvers/version-resolver.js.map +1 -0
  94. package/dist/esm/graphql/resolvers/object-type-field-default-value-resolver-generator.js +2 -2
  95. package/dist/esm/graphql/resolvers/object-type-field-default-value-resolver-generator.js.map +1 -1
  96. package/dist/esm/graphql/resolvers/query-mutation-resolvers/mutation-create-resolver.d.ts.map +1 -1
  97. package/dist/esm/graphql/resolvers/query-mutation-resolvers/mutation-create-resolver.js +35 -29
  98. package/dist/esm/graphql/resolvers/query-mutation-resolvers/mutation-create-resolver.js.map +1 -1
  99. package/dist/esm/graphql/resolvers/query-mutation-resolvers/mutation-delete-resolver.d.ts.map +1 -1
  100. package/dist/esm/graphql/resolvers/query-mutation-resolvers/mutation-delete-resolver.js +30 -25
  101. package/dist/esm/graphql/resolvers/query-mutation-resolvers/mutation-delete-resolver.js.map +1 -1
  102. package/dist/esm/graphql/resolvers/query-mutation-resolvers/mutation-update-resolver.d.ts.map +1 -1
  103. package/dist/esm/graphql/resolvers/query-mutation-resolvers/mutation-update-resolver.js +27 -20
  104. package/dist/esm/graphql/resolvers/query-mutation-resolvers/mutation-update-resolver.js.map +1 -1
  105. package/dist/esm/graphql/resolvers/query-mutation-resolvers/query-search-resolver.js +6 -6
  106. package/dist/esm/graphql/resolvers/query-mutation-resolvers/query-search-resolver.js.map +1 -1
  107. package/dist/esm/graphql/resolvers/query-mutation-resolvers/union-type-resolver.js +2 -2
  108. package/dist/esm/graphql/resolvers/query-mutation-resolvers/union-type-resolver.js.map +1 -1
  109. package/dist/esm/graphql/resolvers/types.d.ts +9 -1
  110. package/dist/esm/graphql/resolvers/types.d.ts.map +1 -1
  111. package/dist/esm/graphql/schema-generator.d.ts.map +1 -1
  112. package/dist/esm/graphql/schema-generator.js +11 -10
  113. package/dist/esm/graphql/schema-generator.js.map +1 -1
  114. package/dist/esm/graphql/schema-utils/entry-reference-util.js +8 -8
  115. package/dist/esm/graphql/schema-utils/entry-reference-util.js.map +1 -1
  116. package/dist/esm/graphql/schema-utils/union-type-util.js +3 -3
  117. package/dist/esm/graphql/schema-utils/union-type-util.js.map +1 -1
  118. package/dist/esm/graphql/schema-validator.d.ts.map +1 -1
  119. package/dist/esm/graphql/schema-validator.js +17 -1
  120. package/dist/esm/graphql/schema-validator.js.map +1 -1
  121. package/dist/esm/index.js +2 -0
  122. package/dist/esm/index.js.map +1 -1
  123. package/dist/esm/persistence/cache.d.ts +3 -0
  124. package/dist/esm/persistence/cache.d.ts.map +1 -1
  125. package/dist/esm/persistence/cache.js +6 -15
  126. package/dist/esm/persistence/cache.js.map +1 -1
  127. package/dist/esm/persistence/commit-with-retry.d.ts +16 -0
  128. package/dist/esm/persistence/commit-with-retry.d.ts.map +1 -0
  129. package/dist/esm/persistence/commit-with-retry.js +35 -0
  130. package/dist/esm/persistence/commit-with-retry.js.map +1 -0
  131. package/dist/esm/persistence/git-adapter-call.d.ts +10 -0
  132. package/dist/esm/persistence/git-adapter-call.d.ts.map +1 -0
  133. package/dist/esm/persistence/git-adapter-call.js +24 -0
  134. package/dist/esm/persistence/git-adapter-call.js.map +1 -0
  135. package/dist/esm/persistence/persistence.d.ts +11 -0
  136. package/dist/esm/persistence/persistence.d.ts.map +1 -1
  137. package/dist/esm/persistence/persistence.js +36 -3
  138. package/dist/esm/persistence/persistence.js.map +1 -1
  139. package/package.json +8 -5
  140. package/src/graphql/errors.ts +2 -1
  141. package/src/graphql/input-type-generator.ts +5 -15
  142. package/src/graphql/queries-mutations-generator.ts +51 -10
  143. package/src/graphql/resolvers/commit-message.ts +34 -0
  144. package/src/graphql/resolvers/field-resolvers/version-resolver.ts +8 -0
  145. package/src/graphql/resolvers/query-mutation-resolvers/mutation-create-resolver.ts +40 -29
  146. package/src/graphql/resolvers/query-mutation-resolvers/mutation-delete-resolver.ts +44 -30
  147. package/src/graphql/resolvers/query-mutation-resolvers/mutation-update-resolver.ts +37 -18
  148. package/src/graphql/resolvers/types.ts +18 -1
  149. package/src/graphql/schema-generator.ts +12 -8
  150. package/src/graphql/schema-validator.ts +21 -0
  151. package/src/persistence/cache.ts +7 -13
  152. package/src/persistence/commit-with-retry.ts +47 -0
  153. package/src/persistence/git-adapter-call.ts +27 -0
  154. package/src/persistence/persistence.ts +50 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,38 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.0.0-beta.5] - 2026-11-11
9
+
10
+ ### Added
11
+
12
+ - Add field `_version` to every `@Entry` type and optional argument `expectedVersion` to update and delete mutations,
13
+ so that saving an entry fails with `CONFLICT` instead of overwriting changes made since the entry was read
14
+ - Repeat a mutation against the new branch head, up to three attempts in total, when another commit was added to the
15
+ branch in the meantime, so that concurrent changes to unrelated entries do not cause errors
16
+
17
+ ### Changed
18
+
19
+ - Replace mutation argument `commitMessage` with `commit: { message, body }`, so that commits can explain a change in a
20
+ body in addition to the single-line message; messages containing line breaks are rejected with `BAD_USER_INPUT`
21
+ - Reject schemas with `@Entry` types that have no field `id` of type `ID!` with error `BAD_SCHEMA`
22
+ - Print each argument of generated mutations on its own line, so that argument descriptions in the schema are readable
23
+ - Omit the declaration `directive @oneOf` from the generated schema, as `@oneOf` is built into `graphql` since 16.9
24
+ - Require peer dependency `graphql` in version `^16.11.0`, which `@apollo/server` already required, instead of
25
+ declaring support for versions 14 to 17
26
+ - Require Node.js 22.18 or newer, as required by the upgraded `@graphql-tools` packages, and declare it in `engines`
27
+ - Upgrade to @commitspark/git-adapter 2.0.0-beta.4
28
+
29
+ ### Fixed
30
+
31
+ - Return errors of Git adapters during commits with their error code, e.g. `CONFLICT` or `FORBIDDEN`, instead of
32
+ `INTERNAL_ERROR`
33
+ - Allow writing fields of type `ID` other than the entry ID, e.g. `sku: ID` or `id` of an embedded type, which were
34
+ missing from generated input types
35
+ - Generate a commit message such as `Update MyType "my-id"` if none is given, instead of adapter-specific messages
36
+ (`-`, `undefined`) or failing commits
37
+ - Export `ErrorCode` as a regular enum instead of a `const enum`, so that it can be used at runtime, e.g. in
38
+ `error.extensions.code === ErrorCode.CONFLICT`
39
+
8
40
  ## [2.0.0-beta.4] - 2026-10-14
9
41
 
10
42
  ### Added
package/README.md CHANGED
@@ -24,7 +24,7 @@ There are two common ways to use this library:
24
24
  ```
25
25
  2. By making GraphQL calls over HTTP to this library wrapped in a webserver or Lambda function.
26
26
 
27
- You can find an example Node.js Express web server implementation
27
+ You can find an example Node.js Express web server implementation
28
28
  [here](https://github.com/commitspark/example-http-express).
29
29
 
30
30
  ## Installing Git provider support
@@ -37,7 +37,7 @@ in [this repository](https://github.com/commitspark/git-adapter).
37
37
  |---------------------------------------------------------------------|------------------------------------------------------------|---------------------------------------------|
38
38
  | [GitHub](https://github.com/commitspark/git-adapter-github) | Provides support for Git repositories hosted on github.com | `npm i @commitspark/git-adapter-github` |
39
39
  | [GitLab (SaaS)](https://github.com/commitspark/git-adapter-gitlab) | Provides support for Git repositories hosted on gitlab.com | `npm i @commitspark/git-adapter-gitlab` |
40
- | [Filesystem](https://github.com/commitspark/git-adapter-filesystem) | Provides read-only access to files on the filesystem level | `npm i @commitspark/git-adapter-filesystem` |
40
+ | [Filesystem](https://github.com/commitspark/git-adapter-filesystem) | Provides support for Git repositories in the filesystem | `npm i @commitspark/git-adapter-filesystem` |
41
41
 
42
42
  ## Installing search support
43
43
 
@@ -88,13 +88,22 @@ schema {
88
88
  type Query {
89
89
  everyRocketFlight: [RocketFlight!]
90
90
  RocketFlight(id: ID!): RocketFlight
91
- _typeName(id: ID!): String
91
+ _typeName(id: ID!): String!
92
92
  }
93
93
 
94
94
  type Mutation {
95
- createRocketFlight(id: ID!, data: RocketFlightInput!, commitMessage: String): RocketFlight
96
- updateRocketFlight(id: ID!, data: RocketFlightInput!, commitMessage: String): RocketFlight
97
- deleteRocketFlight(id: ID!, commitMessage: String): ID
95
+ createRocketFlight(id: ID!, data: RocketFlightInput!, commit: _CommitInput): RocketFlight
96
+ updateRocketFlight(id: ID!, data: RocketFlightInput!, expectedVersion: String, commit: _CommitInput): RocketFlight
97
+ deleteRocketFlight(id: ID!, expectedVersion: String, commit: _CommitInput): ID
98
+ }
99
+
100
+ input _CommitInput {
101
+ message: String
102
+ body: String
103
+ }
104
+
105
+ input RocketFlightIdInput {
106
+ id: ID!
98
107
  }
99
108
 
100
109
  input RocketFlightInput {
@@ -105,6 +114,11 @@ input RocketFlightInput {
105
114
  input PayloadInput {
106
115
  weight: Int!
107
116
  }
117
+
118
+ extend type RocketFlight {
119
+ _referencedBy: [ID!]!
120
+ _version: String!
121
+ }
108
122
  ```
109
123
 
110
124
  # Making GraphQL calls
@@ -148,58 +162,6 @@ const rocketFlight = response.data.rocketFlight
148
162
 
149
163
  # Technical documentation
150
164
 
151
- ## API
152
-
153
- ### createClient()
154
-
155
- This function is used to create a Commitspark GraphQL API client instance.
156
-
157
- Argument `gitAdapter` expects a Commitspark git adapter instance which is then used by the client to access the
158
- adapter's Git repository.
159
-
160
- Optional argument `options` supports the following settings:
161
-
162
- * `searchAdapter`: A Commitspark search adapter instance. If set, query `_search` is added to the GraphQL API (see
163
- [Search](#search)).
164
-
165
- ### Client
166
-
167
- #### postGraphQL()
168
-
169
- This function is used to make GraphQL requests.
170
-
171
- Request execution is handled by ApolloServer behind the scenes.
172
-
173
- Argument `request` expects a conventional GraphQL query and supports query variables as well as introspection.
174
-
175
- #### getSchema()
176
-
177
- This function allows retrieving the GraphQL schema extended by Commitspark as a string.
178
-
179
- Compared to schema data obtained through GraphQL introspection, the schema returned by this function also includes
180
- directive declarations and annotations, allowing for development of additional tools that require this information.
181
-
182
- ## Picking from the Git tree
183
-
184
- As Commitspark is Git-based, all GraphQL requests support traversing the Git commit tree by setting the `ref` argument
185
- in library calls to a
186
-
187
- * ref (i.e. commit hash),
188
- * branch name, or
189
- * tag name (light or regular)
190
-
191
- This enables great flexibility, e.g. to use branches in order to enable data (entry) development workflows, to retrieve
192
- a specific (historic) commit where it is guaranteed that entries are immutable, or to retrieve entries by tag such as
193
- one that marks the latest reviewed and approved version in a repository.
194
-
195
- ### Writing data
196
-
197
- Mutation operations work on branch names only and (when successful) each append a new commit on
198
- HEAD in the given branch.
199
-
200
- To guarantee deterministic results, mutations in calls with multiple mutations are processed sequentially (see
201
- the [official GraphQL documentation](https://graphql.org/learn/queries/#multiple-fields-in-mutations) for details).
202
-
203
165
  ## Data model
204
166
 
205
167
  The data model (i.e. schema) is defined in a single GraphQL type definition text file using the
@@ -255,7 +217,7 @@ data:
255
217
  The path of an entry file relative to the entry folder excluding file extension constitutes the entry ID. Entry IDs
256
218
  can contain `/` for logical grouping, however the entry type is always taken from the file's metadata.
257
219
 
258
- Entry IDs are case-sensitive, must map to valid unique file paths within the entries folder, and must not contain
220
+ Entry IDs are case-sensitive, must map to valid unique file paths within the entries folder, and must not contain
259
221
  characters `\ * " < > : | ?` or control characters. Files and folders whose name starts with `.` are ignored by
260
222
  Commitspark.
261
223
 
@@ -391,7 +353,7 @@ query {
391
353
  }
392
354
  ... on SolidRocketMotor {
393
355
  fuelMass
394
- }
356
+ }
395
357
  }
396
358
  }
397
359
  }
@@ -402,27 +364,94 @@ removed:
402
364
 
403
365
  ```json
404
366
  {
405
- "id": "VA256",
367
+ "id": "VA256",
406
368
  "stages": [
407
- {
408
- "__typename": "LiquidRocketMotor",
409
- "fuelTemperature": 21
410
- },
411
- {
412
- "__typename": "SolidRocketMotor",
413
- "fuelMass": 200000
414
- }
369
+ {
370
+ "__typename": "LiquidRocketMotor",
371
+ "fuelTemperature": 21
372
+ },
373
+ {
374
+ "__typename": "SolidRocketMotor",
375
+ "fuelMass": 200000
376
+ }
415
377
  ]
416
378
  }
417
379
  ```
418
380
 
419
- ## Search
381
+ ## Navigating the Git repository
382
+
383
+ As Commitspark is Git-based, `postGraphQL()` and `getSchema()` take a `ref` argument that selects the commit to work
384
+ on. It can be a
385
+
386
+ * branch name,
387
+ * tag name (lightweight or annotated), or
388
+ * commit hash, if supported by the Git adapter
389
+
390
+ ## Reading and writing data
391
+
392
+ ### Queries
393
+
394
+ The given `ref` is resolved to a commit when request processing starts. All queries in a request read data from this
395
+ commit, which is returned as `ref` of the response.
396
+
397
+ ### Mutations
398
+
399
+ Mutations work on branch names only, as they create new commits.
400
+
401
+ Each successful mutation appends a new commit on HEAD of the given branch.
402
+
403
+ #### Multiple mutations in one request
404
+
405
+ To guarantee deterministic results, mutations in a request containing multiple mutations are processed sequentially (see
406
+ the [official GraphQL documentation](https://graphql.org/learn/queries/#multiple-fields-in-mutations) for details). The
407
+ commit internally resolved as branch HEAD for the duration of the request is updated after each successful mutation.
408
+
409
+ #### Mutations from multiple concurrent requests
410
+
411
+ When a repository is written to concurrently, whether through one or several Commitspark instances or from other
412
+ sources, the following logic guards against race conditions and data loss:
413
+
414
+ Every `@Entry` type has a generated field `_version` that changes whenever the stored entry changes. Mutations
415
+ `update<Type>` and `delete<Type>` accept an optional argument `expectedVersion`. If it is given and the entry has a
416
+ different version, the mutation fails with error code `CONFLICT` instead of overwriting changes made in the meantime.
417
+ Callers that let users edit entries are recommended to read `_version` together with the entry and pass it as
418
+ `expectedVersion` when saving, e.g.:
419
+
420
+ ```graphql
421
+ mutation {
422
+ updateMyEntry(id: "my-id", data: { name: "New name" }, expectedVersion: "<_version as read before>") {
423
+ _version
424
+ }
425
+ }
426
+ ```
427
+
428
+ Each mutation is validated (expected version, references, etc.) against the latest commit of the branch and passed to
429
+ the Git adapter together with this commit as expected parent. Git adapters must only add the new commit if the branch
430
+ still points to that parent. If another commit was added to the branch in the meantime, the mutation is validated again
431
+ against the new branch head and committed on top of it, up to three times in total, so that changes to unrelated
432
+ entries do not lead to errors. If the attempts are exhausted, the mutation fails with error code `CONFLICT`.
433
+
434
+ How reliably a Git adapter detects a moved branch depends on its Git provider; see the documentation of the respective
435
+ adapter for limitations.
436
+
437
+ #### Commit messages
438
+
439
+ Mutations accept an optional argument `commit` to describe the commit they create:
440
+
441
+ * `message` summarizes the change in a single line. A message containing line breaks is rejected with error code
442
+ `BAD_USER_INPUT`. If omitted or empty, a message such as `Update RocketFlight "VA256"` is generated from the
443
+ mutation, type and ID of the entry.
444
+ * `body` optionally holds details of the change and may span multiple lines.
445
+
446
+ Both are trimmed. How message and body are stored depends on the Git adapter, e.g. as commit headline and body.
447
+
448
+ ### Search
420
449
 
421
450
  Entries can be searched by text using query `_search` once a search adapter is passed to `createClient()`. How a
422
451
  search is performed (e.g. keyword search, semantic search or a combination of both) depends on the search adapter
423
452
  (see [Installing search support](#installing-search-support)).
424
453
 
425
- ### Marking fields as searchable
454
+ #### Marking fields as searchable
426
455
 
427
456
  Only fields explicitly marked with directive `@Searchable` are searchable. The directive must be declared in the
428
457
  schema and can be used on types and fields:
@@ -457,7 +486,7 @@ The following rules apply:
457
486
  * The directive of a type does not extend to fields of other types used in it. Such types must be marked themselves.
458
487
  * References to other entries are never followed. Each entry is only searchable by its own data.
459
488
 
460
- ### Querying
489
+ #### Search queries
461
490
 
462
491
  ```graphql
463
492
  query {
@@ -513,14 +542,52 @@ The following error codes are returned together with error codes of Git adapters
513
542
  documented [here](https://github.com/commitspark/git-adapter) and error codes of search adapters as
514
543
  documented [here](https://github.com/commitspark/search-adapter):
515
544
 
516
- | Error code | Description |
517
- |------------------------|--------------------------------------------------------------------|
518
- | `BAD_USER_INPUT` | Invalid input data provided by the caller |
519
- | `NOT_FOUND` | Requested resource (entry, type, etc.) does not exist |
520
- | `BAD_REPOSITORY_DATA` | Data in the repository is malformed or invalid according to schema |
521
- | `BAD_SCHEMA` | Schema definition is malformed or invalid |
522
- | `IN_USE` | Entry cannot be deleted because it is referenced by other entries |
523
- | `INTERNAL_ERROR` | Internal processing error |
545
+ | Error code | Description |
546
+ |-----------------------|----------------------------------------------------------------------------------------------|
547
+ | `BAD_USER_INPUT` | Invalid input data provided by the caller |
548
+ | `NOT_FOUND` | Requested resource (entry, type, etc.) does not exist |
549
+ | `BAD_REPOSITORY_DATA` | Data in the repository is malformed or invalid according to schema |
550
+ | `BAD_SCHEMA` | Schema definition is malformed or invalid |
551
+ | `IN_USE` | Entry cannot be deleted because it is referenced by other entries |
552
+ | `CONFLICT` | Entry or branch was changed concurrently (see "Mutations from multiple concurrent requests") |
553
+ | `INTERNAL_ERROR` | Internal processing error |
554
+
555
+ # TypeScript API
556
+
557
+ ## createClient()
558
+
559
+ This function is used to create a Commitspark GraphQL API client instance.
560
+
561
+ Argument `gitAdapter` expects a Commitspark git adapter instance which is then used by the client to access the
562
+ adapter's Git repository.
563
+
564
+ Optional argument `options` supports the following settings:
565
+
566
+ * `searchAdapter`: A Commitspark search adapter instance. If set, query `_search` is added to the GraphQL API (see
567
+ [Search](#search)).
568
+
569
+ ## Client
570
+
571
+ ### postGraphQL()
572
+
573
+ This function is used to make GraphQL requests.
574
+
575
+ Request execution is handled by ApolloServer behind the scenes.
576
+
577
+ Argument `ref` expects a branch name, tag name or commit hash (see
578
+ [Navigating the Git repository](#navigating-the-git-repository)).
579
+
580
+ Argument `request` expects a conventional GraphQL query and supports query variables as well as introspection.
581
+
582
+ ### getSchema()
583
+
584
+ This function allows retrieving the GraphQL schema extended by Commitspark as a string.
585
+
586
+ Compared to schema data obtained through GraphQL introspection, the schema returned by this function also includes
587
+ directive declarations and annotations, allowing for development of additional tools that require this information.
588
+
589
+ Argument `ref` expects a branch name, tag name or commit hash (see
590
+ [Navigating the Git repository](#navigating-the-git-repository)).
524
591
 
525
592
  # License
526
593
 
@@ -1,13 +1,14 @@
1
1
  import { GraphQLError } from 'graphql';
2
2
  import { ErrorCode as GitAdapterErrorCode } from '@commitspark/git-adapter';
3
3
  import { ErrorCode as SearchAdapterErrorCode } from '@commitspark/search-adapter';
4
- export declare const enum ErrorCode {
4
+ export declare enum ErrorCode {
5
5
  BAD_USER_INPUT = "BAD_USER_INPUT",
6
6
  NOT_FOUND = "NOT_FOUND",
7
7
  BAD_REPOSITORY_DATA = "BAD_REPOSITORY_DATA",
8
8
  BAD_SCHEMA = "BAD_SCHEMA",
9
9
  INTERNAL_ERROR = "INTERNAL_ERROR",
10
- IN_USE = "IN_USE"
10
+ IN_USE = "IN_USE",
11
+ CONFLICT = "CONFLICT"
11
12
  }
12
13
  export interface ErrorMetadata {
13
14
  typeName?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/graphql/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,SAAS,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,EAAE,SAAS,IAAI,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAEjF,0BAAkB,SAAS;IACzB,cAAc,mBAAmB;IACjC,SAAS,cAAc;IACvB,mBAAmB,wBAAwB;IAC3C,UAAU,eAAe;IACzB,cAAc,mBAAmB;IACjC,MAAM,WAAW;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,eAAO,MAAM,WAAW,GACtB,SAAS,MAAM,EACf,MAAM,SAAS,GAAG,mBAAmB,GAAG,sBAAsB,EAC9D,UAAU,aAAa,KACtB,YAiBF,CAAA"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/graphql/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,SAAS,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,EAAE,SAAS,IAAI,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAEjF,oBAAY,SAAS;IACnB,cAAc,mBAAmB;IACjC,SAAS,cAAc;IACvB,mBAAmB,wBAAwB;IAC3C,UAAU,eAAe;IACzB,cAAc,mBAAmB;IACjC,MAAM,WAAW;IACjB,QAAQ,aAAa;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,eAAO,MAAM,WAAW,GACtB,SAAS,MAAM,EACf,MAAM,SAAS,GAAG,mBAAmB,GAAG,sBAAsB,EAC9D,UAAU,aAAa,KACtB,YAiBF,CAAA"}
@@ -1,7 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createError = void 0;
3
+ exports.createError = exports.ErrorCode = void 0;
4
4
  const graphql_1 = require("graphql");
5
+ var ErrorCode;
6
+ (function (ErrorCode) {
7
+ ErrorCode["BAD_USER_INPUT"] = "BAD_USER_INPUT";
8
+ ErrorCode["NOT_FOUND"] = "NOT_FOUND";
9
+ ErrorCode["BAD_REPOSITORY_DATA"] = "BAD_REPOSITORY_DATA";
10
+ ErrorCode["BAD_SCHEMA"] = "BAD_SCHEMA";
11
+ ErrorCode["INTERNAL_ERROR"] = "INTERNAL_ERROR";
12
+ ErrorCode["IN_USE"] = "IN_USE";
13
+ ErrorCode["CONFLICT"] = "CONFLICT";
14
+ })(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
5
15
  const createError = (message, code, metaData) => {
6
16
  const serializedFieldValue = typeof metaData.fieldValue === 'object' ||
7
17
  Array.isArray(metaData.fieldValue)
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/graphql/errors.ts"],"names":[],"mappings":";;;AAAA,qCAAsC;AAsB/B,MAAM,WAAW,GAAG,CACzB,OAAe,EACf,IAA8D,EAC9D,QAAuB,EACT,EAAE;IAChB,MAAM,oBAAoB,GACxB,OAAO,QAAQ,CAAC,UAAU,KAAK,QAAQ;QACvC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;QAChC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC;QACrC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAA;IACzB,MAAM,eAAe,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAA;IACvC,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACvC,eAAe,CAAC,UAAU,GAAG,oBAAoB,CAAA;IACnD,CAAC;IAED,OAAO,IAAI,sBAAY,CAAC,OAAO,EAAE;QAC/B,UAAU,EAAE;YACV,IAAI,EAAE,IAAI;YACV,WAAW,EAAE,eAAe;SAC7B;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AArBY,QAAA,WAAW,eAqBvB"}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/graphql/errors.ts"],"names":[],"mappings":";;;AAAA,qCAAsC;AAItC,IAAY,SAQX;AARD,WAAY,SAAS;IACnB,8CAAiC,CAAA;IACjC,oCAAuB,CAAA;IACvB,wDAA2C,CAAA;IAC3C,sCAAyB,CAAA;IACzB,8CAAiC,CAAA;IACjC,8BAAiB,CAAA;IACjB,kCAAqB,CAAA;AACvB,CAAC,EARW,SAAS,yBAAT,SAAS,QAQpB;AAWM,MAAM,WAAW,GAAG,CACzB,OAAe,EACf,IAA8D,EAC9D,QAAuB,EACT,EAAE;IAChB,MAAM,oBAAoB,GACxB,OAAO,QAAQ,CAAC,UAAU,KAAK,QAAQ;QACvC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;QAChC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC;QACrC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAA;IACzB,MAAM,eAAe,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAA;IACvC,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACvC,eAAe,CAAC,UAAU,GAAG,oBAAoB,CAAA;IACnD,CAAC;IAED,OAAO,IAAI,sBAAY,CAAC,OAAO,EAAE;QAC/B,UAAU,EAAE;YACV,IAAI,EAAE,IAAI;YACV,WAAW,EAAE,eAAe;SAC7B;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AArBY,QAAA,WAAW,eAqBvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"input-type-generator.d.ts","sourceRoot":"","sources":["../../../src/graphql/input-type-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,iBAAiB,EAEjB,gBAAgB,EAOjB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAkC3D,wBAAgB,0BAA0B,CACxC,oBAAoB,EAAE,oBAAoB,GACzC,MAAM,EAAE,CAeV;AAED,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,iBAAiB,EAAE,GAC/B,MAAM,EAAE,CA8BV;AAED,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,gBAAgB,EAAE,GAC7B,MAAM,EAAE,CAoBV"}
1
+ {"version":3,"file":"input-type-generator.d.ts","sourceRoot":"","sources":["../../../src/graphql/input-type-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,iBAAiB,EAEjB,gBAAgB,EAMjB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAkC3D,wBAAgB,0BAA0B,CACxC,oBAAoB,EAAE,oBAAoB,GACzC,MAAM,EAAE,CAeV;AAED,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,iBAAiB,EAAE,GAC/B,MAAM,EAAE,CA2BV;AAED,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,gBAAgB,EAAE,GAC7B,MAAM,EAAE,CAcV"}
@@ -50,14 +50,13 @@ function generateObjectInputTypeStrings(objectTypes) {
50
50
  return objectTypes.map((objectType) => {
51
51
  const name = objectType.name;
52
52
  const inputTypeName = `${name}Input`;
53
+ const isEntryType = (0, directive_util_ts_1.hasDirective)(objectType, directive_util_ts_1.ENTRY_DIRECTIVE_NAME);
53
54
  let inputType = `input ${inputTypeName} {\n`;
54
55
  let inputTypeFieldStrings = '';
55
56
  for (const fieldsKey in objectType.getFields()) {
56
57
  const field = objectType.getFields()[fieldsKey];
57
- if (((0, graphql_1.isNonNullType)(field.type) &&
58
- (0, graphql_1.isScalarType)(field.type.ofType) &&
59
- field.type.ofType.name === 'ID') ||
60
- ((0, graphql_1.isScalarType)(field.type) && field.type.name === 'ID')) {
58
+ // the ID of an entry is passed as mutation argument instead of as part of the entry data
59
+ if (isEntryType && field.name === 'id') {
61
60
  continue;
62
61
  }
63
62
  const inputTypeString = generateFieldInputTypeString(field.type);
@@ -75,11 +74,11 @@ function generateObjectInputTypeStrings(objectTypes) {
75
74
  });
76
75
  }
77
76
  function generateUnionInputTypeStrings(unionTypes) {
78
- const typeStrings = unionTypes.map((unionType) => {
77
+ return unionTypes.map((unionType) => {
79
78
  if ((0, entry_type_util_ts_1.buildsOnTypeWithEntryDirective)(unionType)) {
80
79
  return '';
81
80
  }
82
- // see https://github.com/graphql/graphql-spec/pull/825
81
+ // `@oneOf` is a directive specified by GraphQL and built into graphql-js since 16.9
83
82
  let unionInputType = `input ${unionType.name}Input @oneOf {\n`;
84
83
  for (const innerType of unionType.getTypes()) {
85
84
  unionInputType += ` ${innerType.name}: ${innerType.name}Input\n`;
@@ -87,9 +86,5 @@ function generateUnionInputTypeStrings(unionTypes) {
87
86
  unionInputType += '}\n';
88
87
  return unionInputType;
89
88
  });
90
- if (typeStrings.join('').length > 0) {
91
- typeStrings.push('directive @oneOf on INPUT_OBJECT\n');
92
- }
93
- return typeStrings;
94
89
  }
95
90
  //# sourceMappingURL=input-type-generator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"input-type-generator.js","sourceRoot":"","sources":["../../../src/graphql/input-type-generator.ts"],"names":[],"mappings":";;AAiDA,gEAiBC;AAED,wEAgCC;AAED,sEAsBC;AA5HD,qCAcgB;AAEhB,0EAAkF;AAClF,wEAGyC;AAEzC,SAAS,4BAA4B,CAAC,IAAyB;IAC7D,IAAI,IAAA,oBAAU,EAAC,IAAI,CAAC,EAAE,CAAC;QACrB,OAAO,IAAI,4BAA4B,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAA;IACzD,CAAC;SAAM,IAAI,IAAA,uBAAa,EAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,OAAO,GAAG,4BAA4B,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAA;IACxD,CAAC;SAAM,IAAI,IAAA,sBAAY,EAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,IAAI,IAAA,gCAAY,EAAC,IAAI,EAAE,wCAAoB,CAAC,EAAE,CAAC;YAC7C,OAAO,GAAG,IAAI,CAAC,IAAI,SAAS,CAAA;QAC9B,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,I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YAC/C,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC,CAAA;YAC/C,yFAAyF;YACzF,IAAI,WAAW,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBACvC,SAAQ;YACV,CAAC;YACD,MAAM,eAAe,GAAG,4BAA4B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YAChE,qBAAqB,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,eAAe,IAAI,CAAA;QAClE,CAAC;QAED,IAAI,qBAAqB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrC,SAAS,IAAI,GAAG,qBAAqB,EAAE,CAAA;QACzC,CAAC;aAAM,CAAC;YACN,gEAAgE;YAChE,SAAS,IAAI,gBAAgB,CAAA;QAC/B,CAAC;QACD,SAAS,IAAI,KAAK,CAAA;QAElB,OAAO,SAAS,CAAA;IAClB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAgB,6BAA6B,CAC3C,UAA8B;IAE9B,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAU,EAAE;QAC1C,IAAI,IAAA,mDAA8B,EAAC,SAAS,CAAC,EAAE,CAAC;YAC9C,OAAO,EAAE,CAAA;QACX,CAAC;QAED,oFAAoF;QACpF,IAAI,cAAc,GAAG,SAAS,SAAS,CAAC,IAAI,kBAAkB,CAAA;QAC9D,KAAK,MAAM,SAAS,IAAI,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC;YAC7C,cAAc,IAAI,KAAK,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,SAAS,CAAA;QACnE,CAAC;QACD,cAAc,IAAI,KAAK,CAAA;QACvB,OAAO,cAAc,CAAA;IACvB,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -1,15 +1,15 @@
1
1
  import { EntryData } from '@commitspark/git-adapter';
2
2
  import { GraphQLObjectType } from 'graphql';
3
- import { QueryMutationResolver, ReferencedByResolver, SearchQueryResolver } from './resolvers/types.ts';
3
+ import { QueryMutationResolver, ReferencedByResolver, SearchQueryResolver, VersionResolver } from './resolvers/types.ts';
4
4
  export declare function generateQueriesAndMutations(entryDirectiveTypes: GraphQLObjectType[]): GeneratedSchema[];
5
+ export declare function generateCommitInputType(): string;
5
6
  export declare function generateTypeNameQuery(): GeneratedQuery;
6
7
  export declare function generateSearchQuery(): GeneratedSearchQuery;
7
- export declare function generateReferencedByFields(entryDirectiveTypes: GraphQLObjectType[]): GeneratedField[];
8
- interface GeneratedField {
8
+ export declare function generateEntryFields(entryDirectiveTypes: GraphQLObjectType[]): GeneratedEntryFields[];
9
+ interface GeneratedEntryFields {
9
10
  typeName: string;
10
- name: string;
11
11
  typeExtensionString: string;
12
- resolver: ReferencedByResolver;
12
+ resolvers: Record<string, ReferencedByResolver | VersionResolver>;
13
13
  }
14
14
  export interface GeneratedSearchQuery {
15
15
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"queries-mutations-generator.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries-mutations-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAS3C,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,sBAAsB,CAAA;AAE7B,wBAAgB,2BAA2B,CACzC,mBAAmB,EAAE,iBAAiB,EAAE,GACvC,eAAe,EAAE,CAmGnB;AAED,wBAAgB,qBAAqB,IAAI,cAAc,CAStD;AAED,wBAAgB,mBAAmB,IAAI,oBAAoB,CAiB1D;AAED,wBAAgB,0BAA0B,CACxC,mBAAmB,EAAE,iBAAiB,EAAE,GACvC,cAAc,EAAE,CAYlB;AAED,UAAU,cAAc;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,mBAAmB,EAAE,MAAM,CAAA;IAC3B,QAAQ,EAAE,oBAAoB,CAAA;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,oBAAoB,EAAE,MAAM,CAAA;IAC5B,QAAQ,EAAE,mBAAmB,CAAA;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,cAAc,CAAA;IAC1B,SAAS,EAAE,cAAc,CAAA;IACzB,cAAc,EAAE,cAAc,CAAA;IAC9B,cAAc,EAAE,cAAc,CAAA;IAC9B,cAAc,EAAE,cAAc,CAAA;CAC/B;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,qBAAqB,CAAC,SAAS,GAAG,SAAS,EAAE,GAAG,MAAM,CAAC,CAAA;CAClE"}
1
+ {"version":3,"file":"queries-mutations-generator.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries-mutations-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAU3C,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EAChB,MAAM,sBAAsB,CAAA;AAI7B,wBAAgB,2BAA2B,CACzC,mBAAmB,EAAE,iBAAiB,EAAE,GACvC,eAAe,EAAE,CA+GnB;AAED,wBAAgB,uBAAuB,IAAI,MAAM,CAgBhD;AAED,wBAAgB,qBAAqB,IAAI,cAAc,CAStD;AAED,wBAAgB,mBAAmB,IAAI,oBAAoB,CAiB1D;AAED,wBAAgB,mBAAmB,CACjC,mBAAmB,EAAE,iBAAiB,EAAE,GACvC,oBAAoB,EAAE,CAoBxB;AAED,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,eAAe,CAAC,CAAA;CAClE;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,oBAAoB,EAAE,MAAM,CAAA;IAC5B,QAAQ,EAAE,mBAAmB,CAAA;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,cAAc,CAAA;IAC1B,SAAS,EAAE,cAAc,CAAA;IACzB,cAAc,EAAE,cAAc,CAAA;IAC9B,cAAc,EAAE,cAAc,CAAA;IAC9B,cAAc,EAAE,cAAc,CAAA;CAC/B;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,qBAAqB,CAAC,SAAS,GAAG,SAAS,EAAE,GAAG,MAAM,CAAC,CAAA;CAClE"}
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateQueriesAndMutations = generateQueriesAndMutations;
4
+ exports.generateCommitInputType = generateCommitInputType;
4
5
  exports.generateTypeNameQuery = generateTypeNameQuery;
5
6
  exports.generateSearchQuery = generateSearchQuery;
6
- exports.generateReferencedByFields = generateReferencedByFields;
7
+ exports.generateEntryFields = generateEntryFields;
7
8
  const query_every_resolver_ts_1 = require("./resolvers/query-mutation-resolvers/query-every-resolver.js");
8
9
  const query_by_id_resolver_ts_1 = require("./resolvers/query-mutation-resolvers/query-by-id-resolver.js");
9
10
  const mutation_create_resolver_ts_1 = require("./resolvers/query-mutation-resolvers/mutation-create-resolver.js");
@@ -12,6 +13,8 @@ const mutation_delete_resolver_ts_1 = require("./resolvers/query-mutation-resolv
12
13
  const query_type_by_id_resolver_ts_1 = require("./resolvers/query-mutation-resolvers/query-type-by-id-resolver.js");
13
14
  const query_search_resolver_ts_1 = require("./resolvers/query-mutation-resolvers/query-search-resolver.js");
14
15
  const referenced_by_resolver_ts_1 = require("./resolvers/field-resolvers/referenced-by-resolver.js");
16
+ const version_resolver_ts_1 = require("./resolvers/field-resolvers/version-resolver.js");
17
+ const commitInputTypeName = '_CommitInput';
15
18
  function generateQueriesAndMutations(entryDirectiveTypes) {
16
19
  return entryDirectiveTypes.map((objectType) => {
17
20
  const typeName = objectType.name;
@@ -24,14 +27,24 @@ function generateQueriesAndMutations(entryDirectiveTypes) {
24
27
  const queryByIdString = `${queryByIdName}(id: ID!): ${objectType.name}`;
25
28
  const queryByIdResolverFunc = (source, args, context, info) => (0, query_by_id_resolver_ts_1.queryByIdResolver)(source, args, { ...context, type: objectType }, info);
26
29
  const inputTypeName = `${typeName}Input`;
30
+ // mutations are printed with one argument per line, as indented within the generated root type
31
+ const commitArgument = (operation) => ' """\n' +
32
+ ` Details of the commit. If no message is given, the message is '${operation} ${typeName} "<id>"'.\n` +
33
+ ' """\n' +
34
+ ` commit: ${commitInputTypeName}\n`;
35
+ const expectedVersionArgument = ' """\n' +
36
+ ' Version of the entry (field `_version`) that the change is based on. If given and the entry has a different\n' +
37
+ ' version, the mutation fails with error code CONFLICT instead of overwriting changes made since.\n' +
38
+ ' """\n' +
39
+ ' expectedVersion: String\n';
27
40
  const createMutationName = `create${typeName}`;
28
- const createMutationString = `${createMutationName}(id: ID!, data: ${inputTypeName}!, commitMessage: String): ${typeName}`;
41
+ const createMutationString = `${createMutationName}(\n id: ID!\n data: ${inputTypeName}!\n${commitArgument('Create')} ): ${typeName}`;
29
42
  const createMutationResolver = (source, args, context, info) => (0, mutation_create_resolver_ts_1.mutationCreateResolver)(source, args, { ...context, type: objectType }, info);
30
43
  const updateMutationName = `update${typeName}`;
31
- const updateMutationString = `${updateMutationName}(id: ID!, data: ${inputTypeName}!, commitMessage: String): ${typeName}`;
44
+ const updateMutationString = `${updateMutationName}(\n id: ID!\n data: ${inputTypeName}!\n${expectedVersionArgument}${commitArgument('Update')} ): ${typeName}`;
32
45
  const updateMutationResolver = (source, args, context, info) => (0, mutation_update_resolver_ts_1.mutationUpdateResolver)(source, args, { ...context, type: objectType }, info);
33
46
  const deleteMutationName = `delete${typeName}`;
34
- const deleteMutationString = `${deleteMutationName}(id: ID!, commitMessage: String): ID`;
47
+ const deleteMutationString = `${deleteMutationName}(\n id: ID!\n${expectedVersionArgument}${commitArgument('Delete')} ): ID`;
35
48
  const deleteMutationResolver = (source, args, context, info) => (0, mutation_delete_resolver_ts_1.mutationDeleteResolver)(source, args, { ...context, type: objectType }, info);
36
49
  return {
37
50
  queryEvery: {
@@ -62,6 +75,23 @@ function generateQueriesAndMutations(entryDirectiveTypes) {
62
75
  };
63
76
  });
64
77
  }
78
+ function generateCommitInputType() {
79
+ return `"""
80
+ Details of the commit created by a mutation.
81
+ """
82
+ input ${commitInputTypeName} {
83
+ """
84
+ Commit message summarizing the change in a single line. Leading and trailing whitespace is removed, and messages
85
+ containing line breaks are rejected with error code BAD_USER_INPUT. If omitted or empty, a message is generated.
86
+ """
87
+ message: String
88
+ """
89
+ Optional details of the change, which may span multiple lines. Leading and trailing whitespace is removed.
90
+ """
91
+ body: String
92
+ }
93
+ `;
94
+ }
65
95
  function generateTypeNameQuery() {
66
96
  const entryTypeQueryName = '_typeName';
67
97
  const entryTypeQueryString = `${entryTypeQueryName}(id: ID!): String!`;
@@ -88,16 +118,24 @@ function generateSearchQuery() {
88
118
  resolver: query_search_resolver_ts_1.querySearchResolver,
89
119
  };
90
120
  }
91
- function generateReferencedByFields(entryDirectiveTypes) {
121
+ function generateEntryFields(entryDirectiveTypes) {
92
122
  const referencedByFieldName = '_referencedBy';
123
+ const versionFieldName = '_version';
93
124
  return entryDirectiveTypes.map((objectType) => ({
94
125
  typeName: objectType.name,
95
- name: referencedByFieldName,
96
126
  typeExtensionString: `extend type ${objectType.name} {
97
127
  ${referencedByFieldName}: [ID!]!
128
+ """
129
+ Version of the entry, which changes whenever the stored entry changes. Pass it as \`expectedVersion\` to update
130
+ and delete mutations to prevent overwriting changes made since the entry was read.
131
+ """
132
+ ${versionFieldName}: String!
98
133
  }
99
134
  `,
100
- resolver: referenced_by_resolver_ts_1.referencedByResolver,
135
+ resolvers: {
136
+ [referencedByFieldName]: referenced_by_resolver_ts_1.referencedByResolver,
137
+ [versionFieldName]: version_resolver_ts_1.versionResolver,
138
+ },
101
139
  }));
102
140
  }
103
141
  //# sourceMappingURL=queries-mutations-generator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"queries-mutations-generator.js","sourceRoot":"","sources":["../../../src/graphql/queries-mutations-generator.ts"],"names":[],"mappings":";;AAgBA,kEAqGC;AAED,sDASC;AAED,kDAiBC;AAED,gEAcC;AAjKD,0GAAiG;AACjG,0GAAgG;AAChG,kHAAyG;AACzG,kHAAyG;AACzG,kHAAyG;AACzG,oHAAyG;AACzG,4GAAmG;AACnG,qGAA4F;AAO5F,SAAgB,2BAA2B,CACzC,mBAAwC;IAExC,OAAO,mBAAmB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAmB,EAAE;QAC7D,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAA;QAEhC,8GAA8G;QAC9G,0CAA0C;QAC1C,MAAM,cAAc,GAAG,QAAQ,QAAQ,EAAE,CAAA;QACzC,MAAM,gBAAgB,GAAG,GAAG,cAAc,MAAM,UAAU,CAAC,IAAI,IAAI,CAAA;QACnE,MAAM,sBAAsB,GAAuC,CACjE,MAAM,EACN,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,EAAE,CACF,IAAA,4CAAkB,EAAC,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,IAAI,CAAC,CAAA;QAE1E,MAAM,aAAa,GAAG,QAAQ,CAAA;QAC9B,MAAM,eAAe,GAAG,GAAG,aAAa,cAAc,UAAU,CAAC,IAAI,EAAE,CAAA;QACvE,MAAM,qBAAqB,GAAqC,CAC9D,MAAM,EACN,IAAI,EACJ,OAAO,EACP,IAAI,EACJ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I;QACzB,IAAI,EAAE,qBAAqB;QAC3B,mBAAmB,EAAE,eAAe,UAAU,CAAC,IAAI;IACnD,qBAAqB;;CAExB;QACG,QAAQ,EAAE,gDAAoB;KAC/B,CAAC,CAAC,CAAA;AACL,CAAC"}
1
+ {"version":3,"file":"queries-mutations-generator.js","sourceRoot":"","sources":["../../../src/graphql/queries-mutations-generator.ts"],"names":[],"mappings":";;AAoBA,kEAiHC;AAED,0DAgBC;AAED,sDASC;AAED,kDAiBC;AAED,kDAsBC;AA3MD,0GAAiG;AACjG,0GAAgG;AAChG,kHAAyG;AACzG,kHAAyG;AACzG,kHAAyG;AACzG,oHAAyG;AACzG,4GAAmG;AACnG,qGAA4F;AAC5F,yFAAiF;AAQjF,MAAM,mBAAmB,GAAG,cAAc,CAAA;AAE1C,SAAgB,2BAA2B,CACzC,mBAAwC;IAExC,OAAO,mBAAmB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAmB,EAAE;QAC7D,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAA;QAEhC,8GAA8G;QAC9G,0CAA0C;QAC1C,MAAM,cAAc,GAAG,QAAQ,QAAQ,EAAE,CAAA;QACzC,MAAM,gBAAgB,GAAG,GAAG,cAAc,MAAM,UAAU,CAAC,IAAI,IAAI,CAAA;QACnE,MAAM,sBAAsB,GAAuC,CACjE,MAAM,EACN,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,EAAE,CACF,IAAA,4CAAkB,EAAC,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,IAAI,CAAC,CAAA;QAE1E,MAAM,aAAa,GAAG,QAAQ,CAAA;QAC9B,MAAM,eAAe,GAAG,GAAG,aAAa,cAAc,UAAU,CAAC,IAAI,EAAE,CAAA;QACvE,MAAM,qBAAqB,GAAqC,CAC9D,MAAM,EACN,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,EAAE,CAAC,IAAA,2CAAiB,EAAC,MA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AAA;IACjC,MAAM,iBAAiB,GAAG,YAAY,CAAA;IAEtC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,YAAY,EAAE,GAAG,eAAe,oDAAoD,iBAAiB,KAAK;QAC1G,oBAAoB,EAAE,QAAQ,iBAAiB;;;;;;;CAOlD;QACG,QAAQ,EAAE,8CAAmB;KAC9B,CAAA;AACH,CAAC;AAED,SAAgB,mBAAmB,CACjC,mBAAwC;IAExC,MAAM,qBAAqB,GAAG,eAAe,CAAA;IAC7C,MAAM,gBAAgB,GAAG,UAAU,CAAA;IAEnC,OAAO,mBAAmB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAC9C,QAAQ,EAAE,UAAU,CAAC,IAAI;QACzB,mBAAmB,EAAE,eAAe,UAAU,CAAC,IAAI;IACnD,qBAAqB;;;;;IAKrB,gBAAgB;;CAEnB;QACG,SAAS,EAAE;YACT,CAAC,qBAAqB,CAAC,EAAE,gDAAoB;YAC7C,CAAC,gBAAgB,CAAC,EAAE,qCAAe;SACpC;KACF,CAAC,CAAC,CAAA;AACL,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { CommitDraft } from '@commitspark/git-adapter';
2
+ import { CommitInput } from './types.ts';
3
+ type MutationOperation = 'Create' | 'Update' | 'Delete';
4
+ /**
5
+ * Determines message and body of the commit of a mutation from mutation argument `commit`. The message is trimmed and
6
+ * must be a single line; an omitted or empty message is replaced by a message generated from the mutation. The body
7
+ * is trimmed and omitted if empty.
8
+ */
9
+ export declare function getCommitMessage(commit: CommitInput | null | undefined, operation: MutationOperation, typeName: string, id: string): Pick<CommitDraft, 'message' | 'body'>;
10
+ export {};
11
+ //# sourceMappingURL=commit-message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commit-message.d.ts","sourceRoot":"","sources":["../../../../src/graphql/resolvers/commit-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,KAAK,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEvD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,EACtC,SAAS,EAAE,iBAAiB,EAC5B,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,GACT,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC,CAiBvC"}