@commitspark/graphql-api 0.12.0 → 0.81.0

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 (223) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +215 -97
  3. package/dist/cjs/app/api.service.js +74 -0
  4. package/dist/cjs/app/api.service.js.map +1 -0
  5. package/dist/{container.js → cjs/container.js} +13 -12
  6. package/dist/cjs/container.js.map +1 -0
  7. package/dist/cjs/graphql/apollo-config-factory.service.js +31 -0
  8. package/dist/cjs/graphql/apollo-config-factory.service.js.map +1 -0
  9. package/dist/cjs/graphql/field-resolver/entry-reference-resolver.js +26 -0
  10. package/dist/cjs/graphql/field-resolver/entry-reference-resolver.js.map +1 -0
  11. package/dist/cjs/graphql/field-resolver/field-default-value-resolver.js.map +1 -0
  12. package/dist/cjs/graphql/field-resolver/fieldResolver.js.map +1 -0
  13. package/dist/{graphql → cjs/graphql}/field-resolver/union-value-resolver.js +4 -0
  14. package/dist/cjs/graphql/field-resolver/union-value-resolver.js.map +1 -0
  15. package/dist/{graphql → cjs/graphql}/input-type-generator.service.js +5 -3
  16. package/dist/cjs/graphql/input-type-generator.service.js.map +1 -0
  17. package/dist/{graphql → cjs/graphql}/queries-mutations-generator.service.js +5 -5
  18. package/dist/cjs/graphql/queries-mutations-generator.service.js.map +1 -0
  19. package/dist/{graphql → cjs/graphql}/resolver-generators/mutation-create-resolver-generator.js +22 -12
  20. package/dist/cjs/graphql/resolver-generators/mutation-create-resolver-generator.js.map +1 -0
  21. package/dist/{graphql → cjs/graphql}/resolver-generators/mutation-delete-resolver-generator.js +18 -12
  22. package/dist/cjs/graphql/resolver-generators/mutation-delete-resolver-generator.js.map +1 -0
  23. package/dist/{graphql → cjs/graphql}/resolver-generators/mutation-update-resolver-generator.js +19 -10
  24. package/dist/cjs/graphql/resolver-generators/mutation-update-resolver-generator.js.map +1 -0
  25. package/dist/cjs/graphql/resolver-generators/object-type-field-default-value-resolver-generator.js.map +1 -0
  26. package/dist/cjs/graphql/resolver-generators/query-all-resolver-generator.js +27 -0
  27. package/dist/cjs/graphql/resolver-generators/query-all-resolver-generator.js.map +1 -0
  28. package/dist/cjs/graphql/resolver-generators/query-by-id-resolver-generator.js +25 -0
  29. package/dist/cjs/graphql/resolver-generators/query-by-id-resolver-generator.js.map +1 -0
  30. package/dist/cjs/graphql/resolver-generators/query-count-all-resolver-generator.js +26 -0
  31. package/dist/cjs/graphql/resolver-generators/query-count-all-resolver-generator.js.map +1 -0
  32. package/dist/cjs/graphql/resolver-generators/query-type-by-id-resolver-generator.js +24 -0
  33. package/dist/cjs/graphql/resolver-generators/query-type-by-id-resolver-generator.js.map +1 -0
  34. package/dist/cjs/graphql/resolver-generators/union-type-resolver-generator.js +33 -0
  35. package/dist/cjs/graphql/resolver-generators/union-type-resolver-generator.js.map +1 -0
  36. package/dist/cjs/graphql/schema-analyzer.service.js.map +1 -0
  37. package/dist/cjs/graphql/schema-generator.service.js +103 -0
  38. package/dist/cjs/graphql/schema-generator.service.js.map +1 -0
  39. package/dist/cjs/graphql/schema-root-type-generator.service.js.map +1 -0
  40. package/dist/cjs/graphql/schema-utils/entry-reference-util.js +139 -0
  41. package/dist/cjs/graphql/schema-utils/entry-reference-util.js.map +1 -0
  42. package/dist/cjs/graphql/schema-utils/entry-type-util.js.map +1 -0
  43. package/dist/{graphql → cjs/graphql}/schema-utils/union-type-util.js +2 -0
  44. package/dist/cjs/graphql/schema-utils/union-type-util.js.map +1 -0
  45. package/dist/{graphql → cjs/graphql}/schema-validator.js +2 -2
  46. package/dist/cjs/graphql/schema-validator.js.map +1 -0
  47. package/dist/cjs/index.js +22 -0
  48. package/dist/cjs/index.js.map +1 -0
  49. package/dist/cjs/package.json +1 -0
  50. package/dist/cjs/persistence/persistence.service.js +66 -0
  51. package/dist/cjs/persistence/persistence.service.js.map +1 -0
  52. package/dist/{app → esm/app}/api.service.js +7 -7
  53. package/dist/esm/app/api.service.js.map +1 -0
  54. package/dist/esm/container.js +50 -0
  55. package/dist/esm/container.js.map +1 -0
  56. package/dist/esm/graphql/apollo-config-factory.service.js +17 -0
  57. package/dist/esm/graphql/apollo-config-factory.service.js.map +1 -0
  58. package/dist/{graphql → esm/graphql}/field-resolver/entry-reference-resolver.js +4 -6
  59. package/dist/esm/graphql/field-resolver/entry-reference-resolver.js.map +1 -0
  60. package/dist/esm/graphql/field-resolver/field-default-value-resolver.js +73 -0
  61. package/dist/esm/graphql/field-resolver/field-default-value-resolver.js.map +1 -0
  62. package/dist/esm/graphql/field-resolver/fieldResolver.js +2 -0
  63. package/dist/esm/graphql/field-resolver/fieldResolver.js.map +1 -0
  64. package/dist/esm/graphql/field-resolver/union-value-resolver.js +22 -0
  65. package/dist/esm/graphql/field-resolver/union-value-resolver.js.map +1 -0
  66. package/dist/esm/graphql/input-type-generator.service.js +94 -0
  67. package/dist/esm/graphql/input-type-generator.service.js.map +1 -0
  68. package/dist/esm/graphql/queries-mutations-generator.service.js +85 -0
  69. package/dist/esm/graphql/queries-mutations-generator.service.js.map +1 -0
  70. package/dist/esm/graphql/resolver-generators/mutation-create-resolver-generator.js +78 -0
  71. package/dist/esm/graphql/resolver-generators/mutation-create-resolver-generator.js.map +1 -0
  72. package/dist/esm/graphql/resolver-generators/mutation-delete-resolver-generator.js +58 -0
  73. package/dist/esm/graphql/resolver-generators/mutation-delete-resolver-generator.js.map +1 -0
  74. package/dist/esm/graphql/resolver-generators/mutation-update-resolver-generator.js +67 -0
  75. package/dist/esm/graphql/resolver-generators/mutation-update-resolver-generator.js.map +1 -0
  76. package/dist/esm/graphql/resolver-generators/object-type-field-default-value-resolver-generator.js +55 -0
  77. package/dist/esm/graphql/resolver-generators/object-type-field-default-value-resolver-generator.js.map +1 -0
  78. package/dist/esm/graphql/resolver-generators/query-all-resolver-generator.js +15 -0
  79. package/dist/esm/graphql/resolver-generators/query-all-resolver-generator.js.map +1 -0
  80. package/dist/esm/graphql/resolver-generators/query-by-id-resolver-generator.js +13 -0
  81. package/dist/esm/graphql/resolver-generators/query-by-id-resolver-generator.js.map +1 -0
  82. package/dist/{graphql → esm/graphql}/resolver-generators/query-count-all-resolver-generator.js +2 -5
  83. package/dist/esm/graphql/resolver-generators/query-count-all-resolver-generator.js.map +1 -0
  84. package/dist/esm/graphql/resolver-generators/query-type-by-id-resolver-generator.js +12 -0
  85. package/dist/esm/graphql/resolver-generators/query-type-by-id-resolver-generator.js.map +1 -0
  86. package/dist/{graphql → esm/graphql}/resolver-generators/union-type-resolver-generator.js +6 -5
  87. package/dist/esm/graphql/resolver-generators/union-type-resolver-generator.js.map +1 -0
  88. package/dist/esm/graphql/schema-analyzer.service.js +36 -0
  89. package/dist/esm/graphql/schema-analyzer.service.js.map +1 -0
  90. package/dist/{graphql → esm/graphql}/schema-generator.service.js +24 -16
  91. package/dist/esm/graphql/schema-generator.service.js.map +1 -0
  92. package/dist/esm/graphql/schema-root-type-generator.service.js +35 -0
  93. package/dist/esm/graphql/schema-root-type-generator.service.js.map +1 -0
  94. package/dist/{graphql → esm/graphql}/schema-utils/entry-reference-util.js +22 -23
  95. package/dist/esm/graphql/schema-utils/entry-reference-util.js.map +1 -0
  96. package/dist/esm/graphql/schema-utils/entry-type-util.js +29 -0
  97. package/dist/esm/graphql/schema-utils/entry-type-util.js.map +1 -0
  98. package/dist/esm/graphql/schema-utils/union-type-util.js +18 -0
  99. package/dist/esm/graphql/schema-utils/union-type-util.js.map +1 -0
  100. package/dist/esm/graphql/schema-validator.js +25 -0
  101. package/dist/esm/graphql/schema-validator.js.map +1 -0
  102. package/dist/esm/index.js +7 -0
  103. package/dist/esm/index.js.map +1 -0
  104. package/dist/{persistence → esm/persistence}/persistence.service.js +5 -9
  105. package/dist/esm/persistence/persistence.service.js.map +1 -0
  106. package/dist/tsconfig.build.cjs.tsbuildinfo +1 -0
  107. package/dist/tsconfig.build.esm.tsbuildinfo +1 -0
  108. package/dist/tsconfig.build.types.tsbuildinfo +1 -0
  109. package/dist/{app → types/app}/api.service.d.ts +8 -5
  110. package/dist/types/app/api.service.d.ts.map +1 -0
  111. package/dist/{container.d.ts → types/container.d.ts} +1 -0
  112. package/dist/types/container.d.ts.map +1 -0
  113. package/dist/{graphql → types/graphql}/apollo-config-factory.service.d.ts +1 -0
  114. package/dist/types/graphql/apollo-config-factory.service.d.ts.map +1 -0
  115. package/dist/{graphql → types/graphql}/field-resolver/entry-reference-resolver.d.ts +3 -2
  116. package/dist/types/graphql/field-resolver/entry-reference-resolver.d.ts.map +1 -0
  117. package/dist/{graphql → types/graphql}/field-resolver/field-default-value-resolver.d.ts +3 -2
  118. package/dist/types/graphql/field-resolver/field-default-value-resolver.d.ts.map +1 -0
  119. package/dist/{graphql → types/graphql}/field-resolver/fieldResolver.d.ts +2 -2
  120. package/dist/types/graphql/field-resolver/fieldResolver.d.ts.map +1 -0
  121. package/dist/{graphql → types/graphql}/field-resolver/union-value-resolver.d.ts +2 -1
  122. package/dist/types/graphql/field-resolver/union-value-resolver.d.ts.map +1 -0
  123. package/dist/{graphql → types/graphql}/input-type-generator.service.d.ts +1 -0
  124. package/dist/types/graphql/input-type-generator.service.d.ts.map +1 -0
  125. package/dist/{graphql → types/graphql}/queries-mutations-generator.service.d.ts +2 -2
  126. package/dist/types/graphql/queries-mutations-generator.service.d.ts.map +1 -0
  127. package/dist/{graphql → types/graphql}/resolver-generators/mutation-create-resolver-generator.d.ts +2 -1
  128. package/dist/types/graphql/resolver-generators/mutation-create-resolver-generator.d.ts.map +1 -0
  129. package/dist/{graphql → types/graphql}/resolver-generators/mutation-delete-resolver-generator.d.ts +2 -1
  130. package/dist/types/graphql/resolver-generators/mutation-delete-resolver-generator.d.ts.map +1 -0
  131. package/dist/{graphql → types/graphql}/resolver-generators/mutation-update-resolver-generator.d.ts +2 -1
  132. package/dist/types/graphql/resolver-generators/mutation-update-resolver-generator.d.ts.map +1 -0
  133. package/dist/{graphql → types/graphql}/resolver-generators/object-type-field-default-value-resolver-generator.d.ts +2 -2
  134. package/dist/types/graphql/resolver-generators/object-type-field-default-value-resolver-generator.d.ts.map +1 -0
  135. package/dist/{graphql → types/graphql}/resolver-generators/query-all-resolver-generator.d.ts +2 -1
  136. package/dist/types/graphql/resolver-generators/query-all-resolver-generator.d.ts.map +1 -0
  137. package/dist/{graphql → types/graphql}/resolver-generators/query-by-id-resolver-generator.d.ts +2 -1
  138. package/dist/types/graphql/resolver-generators/query-by-id-resolver-generator.d.ts.map +1 -0
  139. package/dist/{graphql → types/graphql}/resolver-generators/query-count-all-resolver-generator.d.ts +2 -1
  140. package/dist/types/graphql/resolver-generators/query-count-all-resolver-generator.d.ts.map +1 -0
  141. package/dist/{graphql → types/graphql}/resolver-generators/query-type-by-id-resolver-generator.d.ts +2 -1
  142. package/dist/types/graphql/resolver-generators/query-type-by-id-resolver-generator.d.ts.map +1 -0
  143. package/dist/{graphql → types/graphql}/resolver-generators/union-type-resolver-generator.d.ts +1 -0
  144. package/dist/types/graphql/resolver-generators/union-type-resolver-generator.d.ts.map +1 -0
  145. package/dist/{graphql → types/graphql}/schema-analyzer.service.d.ts +2 -2
  146. package/dist/types/graphql/schema-analyzer.service.d.ts.map +1 -0
  147. package/dist/{graphql → types/graphql}/schema-generator.service.d.ts +1 -0
  148. package/dist/types/graphql/schema-generator.service.d.ts.map +1 -0
  149. package/dist/{graphql → types/graphql}/schema-root-type-generator.service.d.ts +1 -0
  150. package/dist/types/graphql/schema-root-type-generator.service.d.ts.map +1 -0
  151. package/dist/{graphql → types/graphql}/schema-utils/entry-reference-util.d.ts +1 -0
  152. package/dist/types/graphql/schema-utils/entry-reference-util.d.ts.map +1 -0
  153. package/dist/{graphql → types/graphql}/schema-utils/entry-type-util.d.ts +1 -0
  154. package/dist/types/graphql/schema-utils/entry-type-util.d.ts.map +1 -0
  155. package/dist/{graphql → types/graphql}/schema-utils/union-type-util.d.ts +1 -0
  156. package/dist/types/graphql/schema-utils/union-type-util.d.ts.map +1 -0
  157. package/dist/{graphql → types/graphql}/schema-validator.d.ts +1 -0
  158. package/dist/types/graphql/schema-validator.d.ts.map +1 -0
  159. package/dist/{index.d.ts → types/index.d.ts} +1 -0
  160. package/dist/types/index.d.ts.map +1 -0
  161. package/dist/{persistence → types/persistence}/persistence.service.d.ts +1 -0
  162. package/dist/types/persistence/persistence.service.d.ts.map +1 -0
  163. package/package.json +29 -17
  164. package/src/app/api.service.ts +13 -7
  165. package/src/container.ts +12 -12
  166. package/src/graphql/field-resolver/entry-reference-resolver.ts +2 -2
  167. package/src/graphql/field-resolver/field-default-value-resolver.ts +2 -4
  168. package/src/graphql/field-resolver/fieldResolver.ts +1 -2
  169. package/src/graphql/field-resolver/union-value-resolver.ts +1 -1
  170. package/src/graphql/input-type-generator.service.ts +1 -1
  171. package/src/graphql/queries-mutations-generator.service.ts +6 -7
  172. package/src/graphql/resolver-generators/mutation-create-resolver-generator.ts +7 -7
  173. package/src/graphql/resolver-generators/mutation-delete-resolver-generator.ts +3 -7
  174. package/src/graphql/resolver-generators/mutation-update-resolver-generator.ts +2 -3
  175. package/src/graphql/resolver-generators/object-type-field-default-value-resolver-generator.ts +4 -6
  176. package/src/graphql/resolver-generators/query-all-resolver-generator.ts +1 -1
  177. package/src/graphql/resolver-generators/query-by-id-resolver-generator.ts +1 -1
  178. package/src/graphql/resolver-generators/query-count-all-resolver-generator.ts +1 -1
  179. package/src/graphql/resolver-generators/query-type-by-id-resolver-generator.ts +1 -1
  180. package/src/graphql/schema-analyzer.service.ts +2 -1
  181. package/src/graphql/schema-generator.service.ts +1 -7
  182. package/src/graphql/schema-utils/entry-reference-util.ts +1 -1
  183. package/src/graphql/schema-validator.ts +1 -3
  184. package/src/persistence/persistence.service.ts +1 -1
  185. package/dist/app/api.service.js.map +0 -1
  186. package/dist/container.js.map +0 -1
  187. package/dist/graphql/apollo-config-factory.service.js +0 -20
  188. package/dist/graphql/apollo-config-factory.service.js.map +0 -1
  189. package/dist/graphql/field-resolver/entry-reference-resolver.js.map +0 -1
  190. package/dist/graphql/field-resolver/field-default-value-resolver.js.map +0 -1
  191. package/dist/graphql/field-resolver/fieldResolver.js.map +0 -1
  192. package/dist/graphql/field-resolver/union-value-resolver.js.map +0 -1
  193. package/dist/graphql/input-type-generator.service.js.map +0 -1
  194. package/dist/graphql/queries-mutations-generator.service.js.map +0 -1
  195. package/dist/graphql/resolver-generators/mutation-create-resolver-generator.js.map +0 -1
  196. package/dist/graphql/resolver-generators/mutation-delete-resolver-generator.js.map +0 -1
  197. package/dist/graphql/resolver-generators/mutation-update-resolver-generator.js.map +0 -1
  198. package/dist/graphql/resolver-generators/object-type-field-default-value-resolver-generator.js.map +0 -1
  199. package/dist/graphql/resolver-generators/query-all-resolver-generator.js +0 -18
  200. package/dist/graphql/resolver-generators/query-all-resolver-generator.js.map +0 -1
  201. package/dist/graphql/resolver-generators/query-by-id-resolver-generator.js +0 -16
  202. package/dist/graphql/resolver-generators/query-by-id-resolver-generator.js.map +0 -1
  203. package/dist/graphql/resolver-generators/query-count-all-resolver-generator.js.map +0 -1
  204. package/dist/graphql/resolver-generators/query-type-by-id-resolver-generator.js +0 -15
  205. package/dist/graphql/resolver-generators/query-type-by-id-resolver-generator.js.map +0 -1
  206. package/dist/graphql/resolver-generators/union-type-resolver-generator.js.map +0 -1
  207. package/dist/graphql/schema-analyzer.service.js.map +0 -1
  208. package/dist/graphql/schema-generator.service.js.map +0 -1
  209. package/dist/graphql/schema-root-type-generator.service.js.map +0 -1
  210. package/dist/graphql/schema-utils/entry-reference-util.js.map +0 -1
  211. package/dist/graphql/schema-utils/entry-type-util.js.map +0 -1
  212. package/dist/graphql/schema-utils/union-type-util.js.map +0 -1
  213. package/dist/graphql/schema-validator.js.map +0 -1
  214. package/dist/index.js +0 -11
  215. package/dist/index.js.map +0 -1
  216. package/dist/persistence/persistence.service.js.map +0 -1
  217. package/dist/tsconfig.build.tsbuildinfo +0 -1
  218. /package/dist/{graphql → cjs/graphql}/field-resolver/field-default-value-resolver.js +0 -0
  219. /package/dist/{graphql → cjs/graphql}/field-resolver/fieldResolver.js +0 -0
  220. /package/dist/{graphql → cjs/graphql}/resolver-generators/object-type-field-default-value-resolver-generator.js +0 -0
  221. /package/dist/{graphql → cjs/graphql}/schema-analyzer.service.js +0 -0
  222. /package/dist/{graphql → cjs/graphql}/schema-root-type-generator.service.js +0 -0
  223. /package/dist/{graphql → cjs/graphql}/schema-utils/entry-type-util.js +0 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,22 @@ 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
+ ## [0.81.0] - 2025-04-13
9
+
10
+ ### Changed
11
+
12
+ - Refactor library packaging to support ESM and CJS
13
+ - Clean up dependencies and relax version constraints
14
+
15
+ ## [0.80.0] - 2025-03-19
16
+
17
+ ### Changed
18
+
19
+ - Rewrite README for clarity
20
+ - Remove superfluous `DeletionResult` type and replace with `ID` scalar in order to simplify API
21
+ - Rename mutation `message` argument to `commitMessage` for more intuitive API use
22
+ - Make mutation `data` argument non-null for more intuitive API use
23
+
8
24
  ## [0.12.0] - 2025-03-17
9
25
 
10
26
  ### Changed
package/README.md CHANGED
@@ -2,96 +2,186 @@
2
2
 
3
3
  [Commitspark](https://commitspark.com) is a set of tools to manage structured data with Git through a GraphQL API.
4
4
 
5
- This library dynamically generates the GraphQL API that allows reading and writing structured data (entries) to and from
6
- a Git repository.
5
+ The library found in this repository provides the GraphQL API that allows reading and writing structured data (entries)
6
+ from and to a Git repository.
7
7
 
8
- Queries and mutations offered by the generated API are determined by a standard GraphQL type definition file (schema)
9
- inside the Git repository.
8
+ Queries and mutations offered by the API are determined by a standard GraphQL type definition file (schema) inside the
9
+ Git repository.
10
10
 
11
11
  Entries (data) are stored using plain YAML text files in the same Git repository. No other data store is needed.
12
12
 
13
- # Running the GraphQL API
13
+ # Installation
14
14
 
15
- There are two common ways to run this library:
15
+ There are two common ways to use this library:
16
16
 
17
- 1. By making GraphQL calls directly against the library as a code dependency in your own JavaScript / TypeScript /
18
- NodeJS application (NPM package name `@commitspark/graphql-api`)
19
- 2. By making GraphQL calls over HTTP to the library wrapped in a webserver or Lambda function of choice
20
- (see the [NodeJS Express server example](https://github.com/commitspark/example-http-express) or
21
- [Lambda function example](https://github.com/commitspark/example-code-serverless))
17
+ 1. By making GraphQL calls directly to the library as a code dependency in your own JavaScript / TypeScript /
18
+ Node.js application.
22
19
 
23
- # Git repository hosting
20
+ To do this, simply install the library with
24
21
 
25
- This library follows an adapter pattern to allow reading from and writing to Git repositories in various locations,
26
- either hosted or locally. When calling the library, pass an adapter instance as needed by your project.
22
+ ```shell
23
+ npm i @commitspark/graphql-api
24
+ ```
25
+ 2. By making GraphQL calls over HTTP to this library wrapped in a webserver or Lambda function of choice.
27
26
 
28
- The following pre-built adapters exist:
27
+ Please see the [Node.js Express server example](https://github.com/commitspark/example-http-express)
28
+ or [Lambda function example](https://github.com/commitspark/example-code-serverless) for details.
29
29
 
30
- | Adapter | Description | NPM package name |
31
- |---------------------------------------------------------------------|------------------------------------------------------------|---------------------------------------|
32
- | [GitHub](https://github.com/commitspark/git-adapter-github) | Provides access to Git repositories hosted on github.com | `@commitspark/git-adapter-github` |
33
- | [GitLab (SaaS)](https://github.com/commitspark/git-adapter-gitlab) | Provides access to Git repositories hosted on gitlab.com | `@commitspark/git-adapter-gitlab` |
34
- | [Filesystem](https://github.com/commitspark/git-adapter-filesystem) | Provides read-only access to files on the filesystem level | `@commitspark/git-adapter-filesystem` |
30
+ ## Installing Git provider support
35
31
 
36
- In case you want to build your own adapter, implement the interfaces found
32
+ This library is agnostic to where a Git repository is stored and relies on separate adapters for repository access. To
33
+ access a Git repository, use one of the pre-built adapters listed below or build your own using the interfaces
37
34
  in [this repository](https://github.com/commitspark/git-adapter).
38
35
 
36
+ | Adapter | Description | Install with |
37
+ |---------------------------------------------------------------------|------------------------------------------------------------|---------------------------------------------|
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
+ | [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` |
41
+
42
+ # Building your GraphQL API
43
+
44
+ Commitspark builds a GraphQL data management API with create, read, update, and delete (CRUD) functionality that is
45
+ solely driven by data types you define in a standard GraphQL schema file in your Git repository.
46
+
47
+ Commitspark achieves this by extending the types in your schema file at runtime with queries, mutations, and additional
48
+ helper types.
49
+
50
+ Let's assume you want to manage information about rocket flights and have already defined the following simple GraphQL
51
+ schema in your Git repository:
52
+
53
+ ```graphql
54
+ # commitspark/schema/schema.graphql
55
+
56
+ directive @Entry on OBJECT
57
+
58
+ type RocketFlight @Entry {
59
+ id: ID!
60
+ vehicleName: String!
61
+ payloads: [Payload!]
62
+ }
63
+
64
+ type Payload {
65
+ weight: Int!
66
+ }
67
+ ```
68
+
69
+ At runtime, when sending a GraphQL request to Commitspark, these are the queries, mutations and helper types that are
70
+ added by Commitspark to your schema for the duration of request execution:
71
+
72
+ ```graphql
73
+ schema {
74
+ query: Query
75
+ mutation: Mutation
76
+ }
77
+
78
+ type Query {
79
+ allRocketFlights: [RocketFlight!]
80
+ RocketFlight(id: ID!): RocketFlight
81
+ _typeName(id: ID!): String
82
+ }
83
+
84
+ type Mutation {
85
+ createRocketFlight(id: ID!, data: RocketFlightInput!, commitMessage: String): RocketFlight
86
+ updateRocketFlight(id: ID!, data: RocketFlightInput!, commitMessage: String): RocketFlight
87
+ deleteRocketFlight(id: ID!, commitMessage: String): ID
88
+ }
89
+
90
+ input RocketFlightInput {
91
+ vehicleName: String!
92
+ payloads: [PayloadInput!]
93
+ }
94
+
95
+ input PayloadInput {
96
+ weight: Int!
97
+ }
98
+ ```
99
+
39
100
  # Making GraphQL calls
40
101
 
41
- ## Picking from the Git tree
102
+ Let's now assume your repository is located on GitHub and you want to query for a single rocket flight.
103
+
104
+ The code to do so could look like this:
105
+
106
+ ```typescript
107
+ import {
108
+ createAdapter,
109
+ GitHubRepositoryOptions,
110
+ } from '@commitspark/git-adapter-github'
111
+ import {getApiService} from '@commitspark/graphql-api'
112
+
113
+ const gitHubAdapter = createAdapter()
114
+ await gitHubAdapter.setRepositoryOptions({
115
+ repositoryOwner: process.env.GITHUB_REPOSITORY_OWNER,
116
+ repositoryName: process.env.GITHUB_REPOSITORY_NAME,
117
+ accessToken: process.env.GITHUB_ACCESS_TOKEN,
118
+ } as GitHubRepositoryOptions)
119
+
120
+ const apiService = await getApiService()
121
+
122
+ const response = await apiService.postGraphQL(
123
+ gitHubAdapter,
124
+ process.env.GIT_BRANCH ?? 'main',
125
+ {
126
+ query: `query ($rocketFlightId: ID!) {
127
+ rocketFlight: RocketFlight(id: $rocketFlightId) {
128
+ vehicleName
129
+ payloads {
130
+ weight
131
+ }
132
+ }
133
+ }`,
134
+ variables: {
135
+ rocketFlightId: 'VA256',
136
+ }
137
+ },
138
+ )
139
+
140
+ const rocketFlight = response.data.rocketFlight
141
+ // ...
142
+ ```
42
143
 
43
- As Commitspark is Git-based, all queries and mutations support traversing the Git commit tree by setting the `ref`
44
- argument in library calls to a
144
+ # Technical documentation
45
145
 
46
- * ref (i.e. commit hash),
47
- * branch name, or
48
- * tag name (light or regular)
146
+ ## API
49
147
 
50
- This enables great flexibility, e.g. to retrieve always the same entries of a specific (historic) commit, to have
51
- different branches with different entries, or to retrieve entries by tag such as one that marks the latest approved
52
- data in a repository.
148
+ ### ApiService
53
149
 
54
- ## Obtaining the generated GraphQL schema
150
+ #### postGraphQL()
55
151
 
56
- At runtime, Commitspark dynamically extends the GraphQL schema found in the schema file with additional
57
- types as well as queries and mutations. This extended schema can be retrieved by calling `getSchema()`.
152
+ This function is used to make GraphQL requests.
58
153
 
59
- Compared to schema data obtained through GraphQL introspection, the schema returned by this function also includes
60
- directive declarations and annotations, allowing for development of additional tools that require this information.
154
+ Request execution is handled by ApolloServer behind the scenes.
61
155
 
62
- ## Reading data
156
+ Argument `request` expects a conventional GraphQL query and supports query variables as well as introspection.
63
157
 
64
- The `request` argument of `postGraphQL()` expects a conventional GraphQL query and supports query variables as well as
65
- introspection. Commitspark also transparently resolves references to other @Entry-annotated GraphQL types (see below),
66
- allowing for retrieval of complex data in a single query as nested result data.
158
+ #### getSchema()
67
159
 
68
- ### Generated queries
160
+ This function allows retrieving the GraphQL schema extended by Commitspark as a string.
69
161
 
70
- For each GraphQL type annotated with `@Entry` in the schema (see below), e.g. `MyType`, the following queries are
71
- generated:
162
+ Compared to schema data obtained through GraphQL introspection, the schema returned by this function also includes
163
+ directive declarations and annotations, allowing for development of additional tools that require this information.
72
164
 
73
- * Query a single entry of a type by ID, e.g. `MyType(id: "..."): MyType`
74
- * Query all entries of a type, e.g. `allMyTypes: [MyType]`
165
+ ## Picking from the Git tree
75
166
 
76
- ## Writing data
167
+ As Commitspark is Git-based, all GraphQL requests support traversing the Git commit tree by setting the `ref` argument
168
+ in library calls to a
77
169
 
78
- The `request` argument of `postGraphQL()` expects a conventional GraphQL mutation and supports mutation variables as
79
- well as introspection. Mutation operations work on branch names only and (when successful) each append a new commit on
80
- HEAD in the given branch. To avoid race conditions, mutations in calls with multiple mutations are processed
81
- sequentially (see the [GraphQL documentation](https://graphql.org/learn/queries/#multiple-fields-in-mutations)).
170
+ * ref (i.e. commit hash),
171
+ * branch name, or
172
+ * tag name (light or regular)
82
173
 
83
- ### Generated mutations
174
+ This enables great flexibility, e.g. to use branches in order to enable data (entry) development workflows, to retrieve
175
+ a specific (historic) commit where it is guaranteed that entries are immutable, or to retrieve entries by tag such as
176
+ one that marks the latest reviewed and approved version in a repository.
84
177
 
85
- For each GraphQL type annotated with `@Entry` (see below), the following mutations are generated:
178
+ ### Writing data
86
179
 
87
- * Create a single entry of a type, e.g.
88
- `createMyType(id: "...", message: "Commit message", data: {...}): MyType`
89
- * Mutate a single entry of a type by ID, e.g.
90
- `updateMyType(id: "...", message: "Commit message", data: {...}): MyType`
91
- * Delete a single entry of a type by ID, e.g.
92
- `deleteMyType(id: "...", message: "Commit message"): { id }`
180
+ Mutation operations work on branch names only and (when successful) each append a new commit on
181
+ HEAD in the given branch.
93
182
 
94
- # Technical documentation
183
+ To guarantee deterministic results, mutations in calls with multiple mutations are processed sequentially (see
184
+ the [official GraphQL documentation](https://graphql.org/learn/queries/#multiple-fields-in-mutations) for details).
95
185
 
96
186
  ## Data model
97
187
 
@@ -109,33 +199,30 @@ Commitspark currently supports the following GraphQL types:
109
199
 
110
200
  ### Data entries
111
201
 
112
- To denote which data is to be given a unique identity for referencing, a directive `@Entry` is
113
- to be declared (this must be done right in the schema file so that the schema remains valid).
114
-
115
- To define the `@Entry` directive, simply add this line to the schema file:
202
+ To denote which data is to be given a unique identity for referencing, Commitspark expects type annotation with
203
+ directive `@Entry`:
116
204
 
117
205
  ```graphql
118
- directive @Entry on OBJECT
119
- ```
206
+ directive @Entry on OBJECT # Important: You must declare this for your schema to be valid
120
207
 
121
- To promote a data type to Entry, annotate the type as follows:
122
-
123
- ```graphql
124
208
  type MyType @Entry {
125
- id: ID!
209
+ id: ID! # Important: Any type annotated with `@Entry` must have such a field
126
210
  # ...
127
211
  }
128
212
  ```
129
213
 
130
- **Important:** Any type annotated with `@Entry` must have a field `id` of type `ID!`.
214
+ **Note:** As a general guideline, you should only apply `@Entry` to data types that meet one of the following
215
+ conditions:
216
+
217
+ * You want to independently create and query instances of this type
218
+ * You want to reference or link to an instance of such a type from multiple other entries
131
219
 
132
- **Note:** Only apply `@Entry` to data types that you actually want to reference or link to from other entries. This
133
- keeps the number of entries low and performance up.
220
+ This keeps the number of entries low and performance up.
134
221
 
135
222
  ## Entry storage
136
223
 
137
224
  Entries, i.e. instances of data types annotated with `@Entry`, are stored as `.yaml` YAML text files inside
138
- a folder `commitspark/entries/` in the repository (unless otherwise configured in your Git adapter).
225
+ folder `commitspark/entries/` in the given Git repository (unless otherwise configured in your Git adapter).
139
226
 
140
227
  The filename (excluding file extension) constitutes the entry ID.
141
228
 
@@ -149,72 +236,103 @@ data:
149
236
  # ... fields of the type as defined in your schema
150
237
  ```
151
238
 
152
- ### Serialization
239
+ ### Serialization / Deserialization
153
240
 
154
241
  #### References
155
242
 
156
- References to types annotated with `@Entry` are stored using a sub-field `id`.
243
+ References to types annotated with `@Entry` are serialized using a sub-field `id`.
157
244
 
158
- For example, consider the following schema:
245
+ For example, consider this variation of our rocket flight schema above:
159
246
 
160
247
  ```graphql
161
- type Page @Entry {
248
+ type RocketFlight @Entry {
162
249
  id: ID!
250
+ operator: Operator
163
251
  }
164
252
 
165
- type Link @Entry {
253
+ type Operator @Entry {
166
254
  id: ID!
167
- target: Page
255
+ fullName: String!
168
256
  }
169
257
  ```
170
258
 
171
- An entry YAML file for a `Link` with ID `myLink` referencing a `Page` with ID `myPage` will look like this:
259
+ An entry YAML file for a `RocketFlight` with ID `VA256` referencing an `Operator` with ID `Arianespace` will look
260
+ like this:
172
261
 
173
262
  ```yaml
263
+ # commitspark/entries/VA256.yaml
174
264
  metadata:
175
- type: Link
265
+ type: RocketFlight
176
266
  referencedBy: [ ]
177
267
  data:
178
- target:
179
- id: myPage
268
+ operator:
269
+ id: Arianespace
180
270
  ```
181
271
 
182
- The entry YAML file of referenced `Page` `myPage` will then look like this:
272
+ The YAML file of referenced `Operator` with ID `Arianespace` will then look like this:
183
273
 
184
274
  ```yaml
275
+ # commitspark/entries/Arianespace.yaml
185
276
  metadata:
186
- type: Page
277
+ type: Operator
187
278
  referencedBy:
188
- - myLink
189
- data: ~
279
+ - VA256
280
+ data:
281
+ fullName: Arianespace SA
282
+ ```
283
+
284
+ When this data is deserialized, Commitspark transparently resolves references to other `@Entry` instances, allowing for
285
+ retrieval of complex, linked data in a single query such as this one:
286
+
287
+ ```graphql
288
+ query {
289
+ RocketFlight(id: "VA256") {
290
+ id
291
+ operator {
292
+ fullName
293
+ }
294
+ }
295
+ }
296
+ ```
297
+
298
+ This returns the following data:
299
+
300
+ ```json
301
+ {
302
+ "id": "VA256",
303
+ "operator": {
304
+ "fullName": "Arianespace SA"
305
+ }
306
+ }
190
307
  ```
191
308
 
192
309
  #### Unions
193
310
 
194
- Consider the following schema where field `contentElements` is an array of Union type `ContentElement`, allowing
195
- different concrete types `Hero` or `Text` to be applied:
311
+ Consider this example of a schema for storing content for a marketing website built out of modular content elements,
312
+ where field `contentElements` is an array of Union type `ContentElement`, allowing different concrete types `Hero` or
313
+ `Text` to be applied:
196
314
 
197
315
  ```graphql
198
316
  type Page @Entry {
199
- id: ID!
200
- contentElements: [ContentElement!]
317
+ id: ID!
318
+ contentElements: [ContentElement!]
201
319
  }
202
320
 
203
321
  union ContentElement =
204
- | Hero
205
- | Text
322
+ | Hero
323
+ | Text
206
324
 
207
325
  type Hero {
208
- heroText: String!
326
+ heroText: String!
209
327
  }
210
328
 
211
329
  type Text {
212
- bodyText: String!
330
+ bodyText: String!
213
331
  }
214
332
  ```
215
333
 
216
334
  During serialization, concrete type instances are represented through an additional nested level of data, using the
217
- instance's type name with a lowercase first character as field name:
335
+ concrete instance's type name as field name:
218
336
 
219
337
  ```yaml
220
338
  metadata:
@@ -222,9 +340,9 @@ metadata:
222
340
  referencedBy: [ ]
223
341
  data:
224
342
  contentElements:
225
- - hero: # represents type `Hero`
343
+ - Hero:
226
344
  heroText: "..."
227
- - text: # represents type `Text`
345
+ - Text:
228
346
  bodyText: "..."
229
347
  ```
230
348
 
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ApiService = void 0;
13
+ const server_1 = require("@apollo/server");
14
+ class ApiService {
15
+ constructor(apolloConfigFactory, schemaGenerator) {
16
+ this.apolloConfigFactory = apolloConfigFactory;
17
+ this.schemaGenerator = schemaGenerator;
18
+ }
19
+ postGraphQL(gitAdapter, ref, request) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ let currentRef = yield gitAdapter.getLatestCommitHash(ref);
22
+ const context = {
23
+ branch: ref,
24
+ gitAdapter: gitAdapter,
25
+ getCurrentRef() {
26
+ return currentRef;
27
+ },
28
+ setCurrentRef(refArg) {
29
+ currentRef = refArg;
30
+ },
31
+ };
32
+ const apolloDriverConfig = yield this.apolloConfigFactory.createGqlOptions(context);
33
+ const apolloServer = new server_1.ApolloServer(Object.assign({}, apolloDriverConfig));
34
+ const result = yield apolloServer.executeOperation(request, {
35
+ contextValue: context,
36
+ });
37
+ yield apolloServer.stop();
38
+ return {
39
+ ref: context.getCurrentRef(),
40
+ data: result.body.kind === 'single'
41
+ ? result.body.singleResult.data
42
+ : undefined,
43
+ errors: result.body.kind === 'single'
44
+ ? result.body.singleResult.errors
45
+ : undefined,
46
+ };
47
+ });
48
+ }
49
+ getSchema(gitAdapter, ref) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ let currentRef = yield gitAdapter.getLatestCommitHash(ref);
52
+ const contextGenerator = () => ({
53
+ branch: ref,
54
+ gitAdapter: gitAdapter,
55
+ getCurrentRef() {
56
+ return currentRef;
57
+ },
58
+ setCurrentRef(refArg) {
59
+ currentRef = refArg;
60
+ },
61
+ });
62
+ const typeDefinitionStrings = (yield this.schemaGenerator.generateSchema(contextGenerator())).typeDefs;
63
+ if (!Array.isArray(typeDefinitionStrings)) {
64
+ throw new Error('Unknown element');
65
+ }
66
+ return {
67
+ ref: contextGenerator().getCurrentRef(),
68
+ data: typeDefinitionStrings.join('\n'),
69
+ };
70
+ });
71
+ }
72
+ }
73
+ exports.ApiService = ApiService;
74
+ //# sourceMappingURL=api.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.service.js","sourceRoot":"","sources":["../../../src/app/api.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAQA,2CAIuB;AAIvB,MAAa,UAAU;IACrB,YACmB,mBAA+C,EAC/C,eAAuC;QADvC,wBAAmB,GAAnB,mBAAmB,CAA4B;QAC/C,oBAAe,GAAf,eAAe,CAAwB;IACvD,CAAC;IAEE,WAAW,CAIf,UAAsB,EACtB,GAAW,EACX,OAEC;;YAED,IAAI,UAAU,GAAG,MAAM,UAAU,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAA;YAC1D,MAAM,OAAO,GAAkB;gBAC7B,MAAM,EAAE,GAAG;gBACX,UAAU,EAAE,UAAU;gBACtB,aAAa;oBACX,OAAO,UAAU,CAAA;gBACnB,CAAC;gBACD,aAAa,CAAC,MAAc;oBAC1B,UAAU,GAAG,MAAM,CAAA;gBACrB,CAAC;aACF,CAAA;YAED,MAAM,kBAAkB,GACtB,MAAM,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAA;YAE1D,MAAM,YAAY,GAAG,IAAI,qBAAY,mBAChC,kBAAkB,EACrB,CAAA;YAEF,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,gBAAgB,CAChD,OAAO,EACP;gBACE,YAAY,EAAE,OAAO;aACtB,CACF,CAAA;YAED,MAAM,YAAY,CAAC,IAAI,EAAE,CAAA;YAEzB,OAAO;gBACL,GAAG,EAAE,OAAO,CAAC,aAAa,EAAE;gBAC5B,IAAI,EACF,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ;oBAC3B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI;oBAC/B,CAAC,CAAC,SAAS;gBACf,MAAM,EACJ,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ;oBAC3B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM;oBACjC,CAAC,CAAC,SAAS;aAChB,CAAA;QACH,CAAC;KAAA;IAEK,SAAS,CACb,UAAsB,EACtB,GAAW;;YAEX,IAAI,UAAU,GAAG,MAAM,UAAU,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAA;YAC1D,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAC5B,CAAC;gBACC,MAAM,EAAE,GAAG;gBACX,UAAU,EAAE,UAAU;gBACtB,aAAa;oBACX,OAAO,UAAU,CAAA;gBACnB,CAAC;gBACD,aAAa,CAAC,MAAc;oBAC1B,UAAU,GAAG,MAAM,CAAA;gBACrB,CAAC;aACgB,CAAA,CAAA;YAErB,MAAM,qBAAqB,GAAG,CAC5B,MAAM,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC,CAC9D,CAAC,QAAQ,CAAA;YACV,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC,EAAE,CAAC;gBAC1C,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;YACpC,CAAC;YAED,OAAO;gBACL,GAAG,EAAE,gBAAgB,EAAE,CAAC,aAAa,EAAE;gBACvC,IAAI,EAAE,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC;aACvC,CAAA;QACH,CAAC;KAAA;CACF;AAtFD,gCAsFC"}
@@ -3,28 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.apiService = void 0;
4
4
  const api_service_1 = require("./app/api.service");
5
5
  const apollo_config_factory_service_1 = require("./graphql/apollo-config-factory.service");
6
+ const entry_reference_resolver_1 = require("./graphql/field-resolver/entry-reference-resolver");
7
+ const entry_reference_util_1 = require("./graphql/schema-utils/entry-reference-util");
8
+ const entry_type_util_1 = require("./graphql/schema-utils/entry-type-util");
9
+ const field_default_value_resolver_1 = require("./graphql/field-resolver/field-default-value-resolver");
6
10
  const input_type_generator_service_1 = require("./graphql/input-type-generator.service");
7
- const queries_mutations_generator_service_1 = require("./graphql/queries-mutations-generator.service");
8
- const schema_analyzer_service_1 = require("./graphql/schema-analyzer.service");
9
- const schema_root_type_generator_service_1 = require("./graphql/schema-root-type-generator.service");
10
- const union_type_resolver_generator_1 = require("./graphql/resolver-generators/union-type-resolver-generator");
11
- const persistence_service_1 = require("./persistence/persistence.service");
12
- const schema_generator_service_1 = require("./graphql/schema-generator.service");
13
11
  const mutation_create_resolver_generator_1 = require("./graphql/resolver-generators/mutation-create-resolver-generator");
14
12
  const mutation_delete_resolver_generator_1 = require("./graphql/resolver-generators/mutation-delete-resolver-generator");
15
13
  const mutation_update_resolver_generator_1 = require("./graphql/resolver-generators/mutation-update-resolver-generator");
14
+ const object_type_field_default_value_resolver_generator_1 = require("./graphql/resolver-generators/object-type-field-default-value-resolver-generator");
15
+ const persistence_service_1 = require("./persistence/persistence.service");
16
+ const queries_mutations_generator_service_1 = require("./graphql/queries-mutations-generator.service");
16
17
  const query_all_resolver_generator_1 = require("./graphql/resolver-generators/query-all-resolver-generator");
17
18
  const query_by_id_resolver_generator_1 = require("./graphql/resolver-generators/query-by-id-resolver-generator");
18
19
  const query_count_all_resolver_generator_1 = require("./graphql/resolver-generators/query-count-all-resolver-generator");
19
20
  const query_type_by_id_resolver_generator_1 = require("./graphql/resolver-generators/query-type-by-id-resolver-generator");
21
+ const schema_analyzer_service_1 = require("./graphql/schema-analyzer.service");
22
+ const schema_generator_service_1 = require("./graphql/schema-generator.service");
23
+ const schema_root_type_generator_service_1 = require("./graphql/schema-root-type-generator.service");
20
24
  const schema_validator_1 = require("./graphql/schema-validator");
21
- const union_value_resolver_1 = require("./graphql/field-resolver/union-value-resolver");
22
- const entry_reference_util_1 = require("./graphql/schema-utils/entry-reference-util");
23
- const object_type_field_default_value_resolver_generator_1 = require("./graphql/resolver-generators/object-type-field-default-value-resolver-generator");
24
- const field_default_value_resolver_1 = require("./graphql/field-resolver/field-default-value-resolver");
25
- const entry_reference_resolver_1 = require("./graphql/field-resolver/entry-reference-resolver");
25
+ const union_type_resolver_generator_1 = require("./graphql/resolver-generators/union-type-resolver-generator");
26
26
  const union_type_util_1 = require("./graphql/schema-utils/union-type-util");
27
- const entry_type_util_1 = require("./graphql/schema-utils/entry-type-util");
27
+ const union_value_resolver_1 = require("./graphql/field-resolver/union-value-resolver");
28
+ // we used to have a DI container here, however that doesn't work well with webpack & co, so doing it by hand for now
28
29
  const schemaValidator = new schema_validator_1.SchemaValidator();
29
30
  const persistenceService = new persistence_service_1.PersistenceService();
30
31
  const entryTypeUtil = new entry_type_util_1.EntryTypeUtil();
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/container.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAC9C,2FAAoF;AACpF,gGAA0F;AAC1F,sFAAgF;AAChF,4EAAsE;AACtE,wGAAiG;AACjG,yFAAkF;AAClF,yHAAkH;AAClH,yHAAkH;AAClH,yHAAkH;AAClH,yJAA+I;AAC/I,2EAAsE;AACtE,uGAAgG;AAChG,6GAAsG;AACtG,iHAAyG;AACzG,yHAAiH;AACjH,2HAAkH;AAClH,+EAAyE;AACzE,iFAA2E;AAC3E,qGAA6F;AAC7F,iEAA4D;AAC5D,+GAAwG;AACxG,4EAAsE;AACtE,wFAAkF;AAElF,qHAAqH;AAErH,MAAM,eAAe,GAAG,IAAI,kCAAe,EAAE,CAAA;AAC7C,MAAM,kBAAkB,GAAG,IAAI,wCAAkB,EAAE,CAAA;AACnD,MAAM,aAAa,GAAG,IAAI,+BAAa,EAAE,CAAA;AACzC,MAAM,aAAa,GAAG,IAAI,+BAAa,EAAE,CAAA;AACzC,MAAM,kBAAkB,GAAG,IAAI,yCAAkB,CAC/C,kBAAkB,EAClB,aAAa,EACb,aAAa,CACd,CAAA;AACD,MAAM,8BAA8B,GAAG,IAAI,mEAA8B,EAAE,CAAA;AAE3E,MAAM,yBAAyB,GAAG,IAAI,wDAAyB,CAAC,aAAa,CAAC,CAAA;AAC9E,MAAM,qBAAqB,GAAG,IAAI,+CAAqB,EAAE,CAAA;AACzD,MAAM,+BAA+B,GAAG,IAAI,oEAA+B,CACzE,kBAAkB,EAClB,kBAAkB,CACnB,CAAA;AACD,MAAM,+BAA+B,GAAG,IAAI,oEAA+B,CACzE,kBAAkB,EAClB,kBAAkB,CACnB,CAAA;AACD,MAAM,+BAA+B,GAAG,IAAI,oEAA+B,CACzE,kBAAkB,EAClB,kBAAkB,CACnB,CAAA;AACD,MAAM,yBAAyB,GAAG,IAAI,wDAAyB,CAC7D,kBAAkB,CACnB,CAAA;AACD,MAAM,0BAA0B,GAAG,IAAI,2DAA0B,CAC/D,kBAAkB,CACnB,CAAA;AACD,MAAM,8BAA8B,GAAG,IAAI,mEAA8B,CACvE,kBAAkB,CACnB,CAAA;AACD,MAAM,8BAA8B,GAAG,IAAI,oEAA8B,CACvE,kBAAkB,CACnB,CAAA;AACD,MAAM,0BAA0B,GAAG,IAAI,0DAA0B,CAC/D,kBAAkB,EAClB,aAAa,CACd,CAAA;AACD,MAAM,kBAAkB,GAAG,IAAI,yCAAkB,CAAC,aAAa,CAAC,CAAA;AAChE,MAAM,sBAAsB,GAAG,IAAI,iDAAsB,CAAC,kBAAkB,CAAC,CAAA;AAC7E,MAAM,yBAAyB,GAAG,IAAI,wDAAyB,CAC7D,aAAa,EACb,kBAAkB,EAClB,sBAAsB,CACvB,CAAA;AACD,MAAM,4CAA4C,GAChD,IAAI,iGAA4C,CAAC,yBAAyB,CAAC,CAAA;AAE7E,MAAM,gCAAgC,GAAG,IAAI,sEAAgC,CAC3E,yBAAyB,EACzB,0BAA0B,EAC1B,8BAA8B,EAC9B,8BAA8B,EAC9B,+BAA+B,EAC/B,+BAA+B,EAC/B,+BAA+B,CAChC,CAAA;AAED,MAAM,sBAAsB,GAAG,IAAI,iDAAsB,CACvD,gCAAgC,EAChC,qBAAqB,EACrB,yBAAyB,EACzB,8BAA8B,EAC9B,0BAA0B,EAC1B,4CAA4C,EAC5C,eAAe,CAChB,CAAA;AAED,MAAM,0BAA0B,GAAG,IAAI,0DAA0B,CAC/D,sBAAsB,CACvB,CAAA;AAEY,QAAA,UAAU,GAAG,IAAI,wBAAU,CACtC,0BAA0B,EAC1B,sBAAsB,CACvB,CAAA"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ApolloConfigFactoryService = void 0;
13
+ const schema_1 = require("@graphql-tools/schema");
14
+ const disabled_1 = require("@apollo/server/plugin/disabled");
15
+ class ApolloConfigFactoryService {
16
+ constructor(schemaGenerator) {
17
+ this.schemaGenerator = schemaGenerator;
18
+ }
19
+ createGqlOptions(context) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const schemaDefinition = yield this.schemaGenerator.generateSchema(context);
22
+ const schema = (0, schema_1.makeExecutableSchema)(schemaDefinition);
23
+ return {
24
+ schema: schema,
25
+ plugins: [(0, disabled_1.ApolloServerPluginUsageReportingDisabled)()],
26
+ };
27
+ });
28
+ }
29
+ }
30
+ exports.ApolloConfigFactoryService = ApolloConfigFactoryService;
31
+ //# sourceMappingURL=apollo-config-factory.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apollo-config-factory.service.js","sourceRoot":"","sources":["../../../src/graphql/apollo-config-factory.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA4D;AAI5D,6DAAyF;AAEzF,MAAa,0BAA0B;IACrC,YAA6B,eAAuC;QAAvC,oBAAe,GAAf,eAAe,CAAwB;IAAG,CAAC;IAElE,gBAAgB,CACpB,OAAsB;;YAEtB,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;YAC3E,MAAM,MAAM,GAAG,IAAA,6BAAoB,EAAC,gBAAgB,CAAC,CAAA;YAErD,OAAO;gBACL,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,CAAC,IAAA,mDAAwC,GAAE,CAAC;aAChB,CAAA;QACzC,CAAC;KAAA;CACF;AAdD,gEAcC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.EntryReferenceResolver = void 0;
13
+ class EntryReferenceResolver {
14
+ constructor(persistence) {
15
+ this.persistence = persistence;
16
+ this.resolve = (fieldValue, args, context, info) => this.resolveFieldValue(fieldValue, args, context, info, info.returnType);
17
+ }
18
+ resolveFieldValue(fieldValue, args, context, info, currentType) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const entry = yield this.persistence.findById(context.gitAdapter, context.getCurrentRef(), fieldValue.id);
21
+ return Object.assign(Object.assign({}, entry.data), { id: entry.id });
22
+ });
23
+ }
24
+ }
25
+ exports.EntryReferenceResolver = EntryReferenceResolver;
26
+ //# sourceMappingURL=entry-reference-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-reference-resolver.js","sourceRoot":"","sources":["../../../../src/graphql/field-resolver/entry-reference-resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAaA,MAAa,sBAAsB;IAQjC,YAA6B,WAA+B;QAA/B,gBAAW,GAAX,WAAW,CAAoB;QAC1D,IAAI,CAAC,OAAO,GAAG,CACb,UAAU,EACV,IAAS,EACT,OAA6B,EAC7B,IAAI,EACwD,EAAE,CAC9D,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;IAC5E,CAAC;IAEa,iBAAiB,CAC7B,UAAe,EACf,IAAS,EACT,OAA6B,EAC7B,IAAwB,EACxB,WAA8B;;YAE9B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAC3C,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,aAAa,EAAE,EACvB,UAAU,CAAC,EAAE,CACd,CAAA;YAED,uCAAY,KAAK,CAAC,IAAI,KAAE,EAAE,EAAE,KAAK,CAAC,EAAE,IAAE;QACxC,CAAC;KAAA;CACF;AAjCD,wDAiCC"}