@commitspark/graphql-api 0.9.4 → 0.11.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 (95) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +96 -85
  3. package/dist/container.js +21 -13
  4. package/dist/container.js.map +1 -1
  5. package/dist/graphql/field-resolver/entry-reference-resolver.d.ts +10 -0
  6. package/dist/graphql/field-resolver/entry-reference-resolver.js +15 -0
  7. package/dist/graphql/field-resolver/entry-reference-resolver.js.map +1 -0
  8. package/dist/graphql/field-resolver/field-default-value-resolver.d.ts +14 -0
  9. package/dist/graphql/field-resolver/field-default-value-resolver.js +73 -0
  10. package/dist/graphql/field-resolver/field-default-value-resolver.js.map +1 -0
  11. package/dist/graphql/field-resolver/fieldResolver.d.ts +11 -0
  12. package/dist/graphql/field-resolver/fieldResolver.js +3 -0
  13. package/dist/graphql/field-resolver/fieldResolver.js.map +1 -0
  14. package/dist/graphql/field-resolver/union-value-resolver.d.ts +10 -0
  15. package/dist/graphql/field-resolver/union-value-resolver.js +17 -0
  16. package/dist/graphql/field-resolver/union-value-resolver.js.map +1 -0
  17. package/dist/graphql/input-type-generator.service.d.ts +3 -3
  18. package/dist/graphql/input-type-generator.service.js +18 -7
  19. package/dist/graphql/input-type-generator.service.js.map +1 -1
  20. package/dist/graphql/queries-mutations-generator.service.d.ts +7 -7
  21. package/dist/graphql/queries-mutations-generator.service.js +6 -6
  22. package/dist/graphql/queries-mutations-generator.service.js.map +1 -1
  23. package/dist/graphql/resolver-generators/mutation-create-resolver-generator.d.ts +6 -3
  24. package/dist/graphql/resolver-generators/mutation-create-resolver-generator.js +46 -4
  25. package/dist/graphql/resolver-generators/mutation-create-resolver-generator.js.map +1 -1
  26. package/dist/graphql/resolver-generators/mutation-delete-resolver-generator.d.ts +6 -3
  27. package/dist/graphql/resolver-generators/mutation-delete-resolver-generator.js +32 -9
  28. package/dist/graphql/resolver-generators/mutation-delete-resolver-generator.js.map +1 -1
  29. package/dist/graphql/resolver-generators/mutation-update-resolver-generator.d.ts +12 -0
  30. package/dist/graphql/resolver-generators/mutation-update-resolver-generator.js +53 -0
  31. package/dist/graphql/resolver-generators/mutation-update-resolver-generator.js.map +1 -0
  32. package/dist/graphql/resolver-generators/object-type-field-default-value-resolver-generator.d.ts +13 -0
  33. package/dist/graphql/resolver-generators/object-type-field-default-value-resolver-generator.js +58 -0
  34. package/dist/graphql/resolver-generators/object-type-field-default-value-resolver-generator.js.map +1 -0
  35. package/dist/graphql/resolver-generators/query-all-resolver-generator.d.ts +3 -2
  36. package/dist/graphql/resolver-generators/query-all-resolver-generator.js +4 -1
  37. package/dist/graphql/resolver-generators/query-all-resolver-generator.js.map +1 -1
  38. package/dist/graphql/resolver-generators/query-by-id-resolver-generator.d.ts +3 -2
  39. package/dist/graphql/resolver-generators/query-by-id-resolver-generator.js +2 -1
  40. package/dist/graphql/resolver-generators/query-by-id-resolver-generator.js.map +1 -1
  41. package/dist/graphql/resolver-generators/union-type-resolver-generator.d.ts +4 -4
  42. package/dist/graphql/resolver-generators/union-type-resolver-generator.js +3 -3
  43. package/dist/graphql/resolver-generators/union-type-resolver-generator.js.map +1 -1
  44. package/dist/graphql/schema-analyzer.service.d.ts +1 -9
  45. package/dist/graphql/schema-analyzer.service.js +6 -17
  46. package/dist/graphql/schema-analyzer.service.js.map +1 -1
  47. package/dist/graphql/schema-generator.service.d.ts +3 -5
  48. package/dist/graphql/schema-generator.service.js +7 -12
  49. package/dist/graphql/schema-generator.service.js.map +1 -1
  50. package/dist/graphql/schema-utils/entry-reference-util.d.ts +12 -4
  51. package/dist/graphql/schema-utils/entry-reference-util.js +105 -21
  52. package/dist/graphql/schema-utils/entry-reference-util.js.map +1 -1
  53. package/dist/graphql/schema-utils/entry-type-util.d.ts +6 -0
  54. package/dist/graphql/schema-utils/entry-type-util.js +34 -0
  55. package/dist/graphql/schema-utils/entry-type-util.js.map +1 -0
  56. package/dist/graphql/schema-utils/union-type-util.d.ts +5 -0
  57. package/dist/graphql/schema-utils/union-type-util.js +21 -0
  58. package/dist/graphql/schema-utils/union-type-util.js.map +1 -0
  59. package/dist/persistence/persistence.service.d.ts +1 -8
  60. package/dist/persistence/persistence.service.js +22 -87
  61. package/dist/persistence/persistence.service.js.map +1 -1
  62. package/dist/tsconfig.build.tsbuildinfo +1 -1
  63. package/package.json +3 -3
  64. package/src/container.ts +29 -15
  65. package/src/graphql/field-resolver/entry-reference-resolver.ts +47 -0
  66. package/src/graphql/field-resolver/field-default-value-resolver.ts +154 -0
  67. package/src/graphql/field-resolver/fieldResolver.ts +19 -0
  68. package/src/graphql/field-resolver/union-value-resolver.ts +46 -0
  69. package/src/graphql/input-type-generator.service.ts +22 -8
  70. package/src/graphql/queries-mutations-generator.service.ts +18 -18
  71. package/src/graphql/resolver-generators/mutation-create-resolver-generator.ts +82 -19
  72. package/src/graphql/resolver-generators/mutation-delete-resolver-generator.ts +72 -27
  73. package/src/graphql/resolver-generators/mutation-update-resolver-generator.ts +128 -0
  74. package/src/graphql/resolver-generators/object-type-field-default-value-resolver-generator.ts +119 -0
  75. package/src/graphql/resolver-generators/query-all-resolver-generator.ts +9 -7
  76. package/src/graphql/resolver-generators/query-by-id-resolver-generator.ts +7 -7
  77. package/src/graphql/resolver-generators/union-type-resolver-generator.ts +5 -7
  78. package/src/graphql/schema-analyzer.service.ts +10 -24
  79. package/src/graphql/schema-generator.service.ts +13 -22
  80. package/src/graphql/schema-utils/entry-reference-util.ts +170 -30
  81. package/src/graphql/schema-utils/entry-type-util.ts +42 -0
  82. package/src/graphql/schema-utils/union-type-util.ts +23 -0
  83. package/src/persistence/persistence.service.ts +30 -142
  84. package/dist/graphql/resolver-generators/entry-reference-resolver.generator.d.ts +0 -12
  85. package/dist/graphql/resolver-generators/entry-reference-resolver.generator.js +0 -29
  86. package/dist/graphql/resolver-generators/entry-reference-resolver.generator.js.map +0 -1
  87. package/dist/graphql/resolver-generators/mutation-update.resolver-generator.d.ts +0 -8
  88. package/dist/graphql/resolver-generators/mutation-update.resolver-generator.js +0 -29
  89. package/dist/graphql/resolver-generators/mutation-update.resolver-generator.js.map +0 -1
  90. package/dist/graphql/resolver-generators/union-value-resolver-generator.d.ts +0 -13
  91. package/dist/graphql/resolver-generators/union-value-resolver-generator.js +0 -80
  92. package/dist/graphql/resolver-generators/union-value-resolver-generator.js.map +0 -1
  93. package/src/graphql/resolver-generators/entry-reference-resolver.generator.ts +0 -71
  94. package/src/graphql/resolver-generators/mutation-update.resolver-generator.ts +0 -59
  95. package/src/graphql/resolver-generators/union-value-resolver-generator.ts +0 -125
package/CHANGELOG.md CHANGED
@@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.11.0] - 2024-08-17
8
+ ### Changed
9
+ - Upgrade to `@commitspark/git-adapter` 0.13.0
10
+
11
+ ## [0.10.0] - 2024-06-15
12
+ ### Added
13
+ - Add referential integrity by tracking and validating references between entries
14
+ - Add support of partial updates
15
+
16
+ ### Fixed
17
+ - [#18](https://github.com/commitspark/graphql-api/issues/18), [#25](https://github.com/commitspark/graphql-api/issues/25)
18
+ Fix handling of entries that only have an `id` field
19
+
20
+ ### Changed
21
+ - Return default data where possible when entry data is incomplete
22
+ - Improve content retrieval performance
23
+
7
24
  ## [0.9.4] - 2023-11-14
8
25
  ### Fixed
9
26
  - Fix invalid schema built when running under Next.js 14
package/README.md CHANGED
@@ -1,61 +1,31 @@
1
1
  # Introduction
2
2
 
3
- **This library dynamically generates a GraphQL API that allows reading and writing structured text content to and from a
4
- Git repository.**
3
+ [Commitspark](https://commitspark.com) is a set of tools to manage structured data with Git through a GraphQL API.
5
4
 
6
- Queries and mutations offered by the generated API are determined by a vanilla GraphQL type definition file inside the
7
- Git repository.
5
+ This library dynamically generates the GraphQL API that allows reading and writing structured data (entries) to and from
6
+ a Git repository.
8
7
 
9
- Content is stored using plain YAML text files in the same Git repository. No other data store or configuration is
10
- needed.
8
+ Queries and mutations offered by the generated API are determined by a standard GraphQL type definition file (schema)
9
+ inside the Git repository.
11
10
 
12
- ---
11
+ Entries (data) are stored using plain YAML text files in the same Git repository. No other data store is needed.
13
12
 
14
- *Commitspark is in tech-preview, i.e. it is not yet feature-complete, missing some error handling and tests, and may
15
- implement breaking changes before a first production-ready release.*
16
-
17
- # Usage
18
-
19
- Use this library to query structured content from a Git repository via GraphQL e.g. in order to fill frontends such as a
20
- Next.js-based website with content. The generated GraphQL API is similar to those offered by headless content management
21
- systems (CMS), only that content comes from a Git repository and not a proprietary storage or API.
22
-
23
- To edit content, either use the [Commitspark user interface](https://commitspark.com) or execute the library's generated
24
- GraphQL mutations yourself. (Or if you know what you're doing, you could even edit the YAML content files directly in a
25
- repository).
26
-
27
- To change the content model, simply modify the GraphQL type definition (schema) file. For details, see below.
28
-
29
- # Running the Commitspark library
13
+ # Running the GraphQL API
30
14
 
31
15
  There are two common ways to run this library:
32
16
 
33
17
  1. By making GraphQL calls directly against the library as a code dependency in your own JavaScript / TypeScript /
34
18
  NodeJS application (NPM package name `@commitspark/graphql-api`)
35
- 2. By making GraphQL calls over HTTP to the library wrapped in
36
- a webserver or Lambda function of choice
37
- ([NodeJS Express server example](https://github.com/commitspark/example-http-express),
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
38
21
  [Lambda function example](https://github.com/commitspark/example-code-serverless))
39
22
 
40
- In both cases, it is recommended to use a dedicated Git repository for content and not use the same repository as used
41
- for application code. See "Git repository hosting" below on where this content repository can be located.
42
-
43
- # Getting started
44
-
45
- If you're new to Commitspark, the quickest way to see Commitspark in action is as follows:
46
-
47
- 1. [Copy the example Git content repository](https://github.com/commitspark/example-content-website/generate)
48
- 2. [Copy the example Next.js application repository](https://github.com/commitspark/example-nextjs/generate)
49
- 3. In the application repository, follow the simple
50
- [README](https://github.com/commitspark/example-nextjs/blob/main/README.md) steps to point Next.js to your content
51
- repository
52
-
53
23
  # Git repository hosting
54
24
 
55
- Commitspark follows an adapter pattern, so it can read from and write to Git repositories in various places, either
56
- hosted or locally. When using the library, pass an adapter instance as needed by your project.
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.
57
27
 
58
- The following adapters exist:
28
+ The following pre-built adapters exist:
59
29
 
60
30
  | Adapter | Description | NPM package name |
61
31
  |---------------------------------------------------------------------|------------------------------------------------------------|---------------------------------------|
@@ -77,28 +47,30 @@ argument in library calls to a
77
47
  * branch name, or
78
48
  * tag name (light or regular)
79
49
 
80
- This enables great flexibility, e.g. to retrieve always the same content of a specific (historic) commit, to have
81
- different branches with different content, or to retrieve content by tag such as reviewed content.
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.
82
53
 
83
54
  ## Obtaining the generated GraphQL schema
84
55
 
85
- Commitspark dynamically extends the GraphQL schema file's content model at runtime with additional types as well as
86
- queries and mutations. This extended schema can be retrieved by calling `getSchema()`.
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()`.
87
58
 
88
- Compared to schema data obtained through GraphQL introspection, the schema returned here also includes directive
89
- declarations and annotations, allowing for development of additional tools that require this information.
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.
90
61
 
91
62
  ## Reading data
92
63
 
93
64
  The `request` argument of `postGraphQL()` expects a conventional GraphQL query and supports query variables as well as
94
- introspection. Commitspark also transparently resolves references between @Entry-annotated content entries (see below),
95
- allowing for retrieval of complex data in a single query.
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.
96
67
 
97
68
  ### Generated queries
98
69
 
99
- For each content type annotated with `@Entry` in the content model (see below), the following queries are generated:
70
+ For each GraphQL type annotated with `@Entry` in the schema (see below), e.g. `MyType`, the following queries are
71
+ generated:
100
72
 
101
- * Query a single entry of a type by ID, e.g. `MyType(id:"..."): MyType`
73
+ * Query a single entry of a type by ID, e.g. `MyType(id: "..."): MyType`
102
74
  * Query all entries of a type, e.g. `allMyTypes: [MyType]`
103
75
 
104
76
  ## Writing data
@@ -108,40 +80,36 @@ well as introspection. Mutation operations work on branch names only and (when s
108
80
  HEAD in the given branch. To avoid race conditions, mutations in calls with multiple mutations are processed
109
81
  sequentially (see the [GraphQL documentation](https://graphql.org/learn/queries/#multiple-fields-in-mutations)).
110
82
 
111
- ### Generated queries
83
+ ### Generated mutations
112
84
 
113
- For each content type annotated with `@Entry` (see below), the following mutations are generated:
85
+ For each GraphQL type annotated with `@Entry` (see below), the following mutations are generated:
114
86
 
115
87
  * Create a single entry of a type, e.g.
116
- `createMyType(id:"...", message:"Commit message", data:{...}): MyType`
88
+ `createMyType(id: "...", message: "Commit message", data: {...}): MyType`
117
89
  * Mutate a single entry of a type by ID, e.g.
118
- `updateMyType(id:"...", message:"Commit message", data:{...}): MyType`
90
+ `updateMyType(id: "...", message: "Commit message", data: {...}): MyType`
119
91
  * Delete a single entry of a type by ID, e.g.
120
- `deleteMyType(id:"...", message:"Commit message"): { id }`
121
-
122
- ## Authenticating with your repository
123
-
124
- Depending on the Git adapter used (see above), an authentication token must be provided. See the corresponding adapter
125
- README for details.
92
+ `deleteMyType(id: "...", message: "Commit message"): { id }`
126
93
 
127
94
  # Technical documentation
128
95
 
129
- ## Content model
96
+ ## Data model
130
97
 
131
- The content model (i.e. schema) is defined in a single GraphQL type definition text file using the
98
+ The data model (i.e. schema) is defined in a single GraphQL type definition text file using the
132
99
  [GraphQL type system](https://graphql.org/learn/schema/).
133
100
 
134
- The schema file must be located at `schema/schema.graphql` inside the Git repository.
101
+ The schema file must be located at `commitspark/schema/schema.graphql` inside the Git repository (unless otherwise
102
+ configured in your Git adapter).
135
103
 
136
- Commitspark currently supports the following data types:
104
+ Commitspark currently supports the following GraphQL types:
137
105
 
138
106
  * `type`
139
107
  * `union`
140
108
  * `enum`
141
109
 
142
- ### Content entries
110
+ ### Data entries
143
111
 
144
- To denote which content type instances are to be given a unique identity for referencing, a directive `@Entry` is
112
+ To denote which data is to be given a unique identity for referencing, a directive `@Entry` is
145
113
  to be declared (this must be done right in the schema file so that the schema remains valid).
146
114
 
147
115
  To define the `@Entry` directive, simply add this line to the schema file:
@@ -150,7 +118,7 @@ To define the `@Entry` directive, simply add this line to the schema file:
150
118
  directive @Entry on OBJECT
151
119
  ```
152
120
 
153
- To promote a content type to Entry, annotate the type as follows:
121
+ To promote a data type to Entry, annotate the type as follows:
154
122
 
155
123
  ```graphql
156
124
  type MyType @Entry {
@@ -161,13 +129,13 @@ type MyType @Entry {
161
129
 
162
130
  **Important:** Any type annotated with `@Entry` must have a field `id` of type `ID!`.
163
131
 
164
- **Note:** Only apply `@Entry` to content types that you actually want to reference or link to from other entries. This
132
+ **Note:** Only apply `@Entry` to data types that you actually want to reference or link to from other entries. This
165
133
  keeps the number of entries low and performance up.
166
134
 
167
- ## Content storage
135
+ ## Entry storage
168
136
 
169
- Content entries, i.e. instances of content types annotated with `@Entry`, are stored as `.yaml` YAML text files inside
170
- a folder `entries` in the repository.
137
+ 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).
171
139
 
172
140
  The filename (excluding file extension) constitutes the entry ID.
173
141
 
@@ -175,13 +143,16 @@ Entry files have the following structure:
175
143
 
176
144
  ```yaml
177
145
  metadata:
178
- type: MyType # name of type as defined in your schema
146
+ type: MyType # name of type as defined in your schema
147
+ referencedBy: [ ] # array of entry IDs that hold a reference to this entry
179
148
  data:
180
149
  # ... fields of the type as defined in your schema
181
150
  ```
182
151
 
183
152
  ### Serialization
184
153
 
154
+ #### References
155
+
185
156
  References to types annotated with `@Entry` are stored using a sub-field `id`.
186
157
 
187
158
  For example, consider the following schema:
@@ -197,27 +168,67 @@ type Link @Entry {
197
168
  }
198
169
  ```
199
170
 
200
- An entry for `Link` referencing a `Page` will look like this:
171
+ An entry YAML file for a `Link` with ID `myLink` referencing a `Page` with ID `myPage` will look like this:
201
172
 
202
173
  ```yaml
203
174
  metadata:
204
- type: Link
175
+ type: Link
176
+ referencedBy: [ ]
205
177
  data:
206
- target:
207
- id: "..." # ID of targeted Page
178
+ target:
179
+ id: myPage
180
+ ```
181
+
182
+ The entry YAML file of referenced `Page` `myPage` will then look like this:
183
+
184
+ ```yaml
185
+ metadata:
186
+ type: Page
187
+ referencedBy:
188
+ - myLink
189
+ data: ~
208
190
  ```
209
191
 
210
- # FAQ
192
+ #### Unions
193
+
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:
196
+
197
+ ```graphql
198
+ type Page @Entry {
199
+ id: ID!
200
+ contentElements: [ContentElement!]
201
+ }
202
+
203
+ union ContentElement =
204
+ | Hero
205
+ | Text
211
206
 
212
- * Q: Do I need to run a web server or serverless function to use Commitspark?
207
+ type Hero {
208
+ heroText: String!
209
+ }
210
+
211
+ type Text {
212
+ bodyText: String!
213
+ }
214
+ ```
213
215
 
214
- A: No. You can pass a GraphQL request string directly to the Commitspark library without going through HTTP. This can
215
- be useful e.g. in CI/CD pipelines where you might not want to bring up a server just to execute a GraphQL query.
216
+ 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:
216
218
 
217
- * Q: Do I really need to have two separate repositories for application code and content?
219
+ ```yaml
220
+ metadata:
221
+ type: Page
222
+ referencedBy: [ ]
223
+ data:
224
+ contentElements:
225
+ - hero: # represents type `Hero`
226
+ heroText: "..."
227
+ - text: # represents type `Text`
228
+ bodyText: "..."
229
+ ```
218
230
 
219
- A: No. You can have both in the same repository but depending on how your software and content workflows are
220
- structured, you may have a hard time finding a workflow that works equally well for both domains.
231
+ When querying data through the API, this additional level of nesting is transparently removed and not visible.
221
232
 
222
233
  # License
223
234
 
package/dist/container.js CHANGED
@@ -3,7 +3,6 @@ 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_generator_1 = require("./graphql/resolver-generators/entry-reference-resolver.generator");
7
6
  const input_type_generator_service_1 = require("./graphql/input-type-generator.service");
8
7
  const queries_mutations_generator_service_1 = require("./graphql/queries-mutations-generator.service");
9
8
  const schema_analyzer_service_1 = require("./graphql/schema-analyzer.service");
@@ -13,32 +12,41 @@ const persistence_service_1 = require("./persistence/persistence.service");
13
12
  const schema_generator_service_1 = require("./graphql/schema-generator.service");
14
13
  const mutation_create_resolver_generator_1 = require("./graphql/resolver-generators/mutation-create-resolver-generator");
15
14
  const mutation_delete_resolver_generator_1 = require("./graphql/resolver-generators/mutation-delete-resolver-generator");
16
- const mutation_update_resolver_generator_1 = require("./graphql/resolver-generators/mutation-update.resolver-generator");
15
+ const mutation_update_resolver_generator_1 = require("./graphql/resolver-generators/mutation-update-resolver-generator");
17
16
  const query_all_resolver_generator_1 = require("./graphql/resolver-generators/query-all-resolver-generator");
18
17
  const query_by_id_resolver_generator_1 = require("./graphql/resolver-generators/query-by-id-resolver-generator");
19
18
  const query_count_all_resolver_generator_1 = require("./graphql/resolver-generators/query-count-all-resolver-generator");
20
19
  const query_type_by_id_resolver_generator_1 = require("./graphql/resolver-generators/query-type-by-id-resolver-generator");
21
20
  const schema_validator_1 = require("./graphql/schema-validator");
22
- const union_value_resolver_generator_1 = require("./graphql/resolver-generators/union-value-resolver-generator");
21
+ const union_value_resolver_1 = require("./graphql/field-resolver/union-value-resolver");
23
22
  const entry_reference_util_1 = require("./graphql/schema-utils/entry-reference-util");
24
- const entryReferenceUtil = new entry_reference_util_1.EntryReferenceUtil();
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");
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");
25
28
  const schemaValidator = new schema_validator_1.SchemaValidator();
26
29
  const persistenceService = new persistence_service_1.PersistenceService();
30
+ const entryTypeUtil = new entry_type_util_1.EntryTypeUtil();
31
+ const unionTypeUtil = new union_type_util_1.UnionTypeUtil();
32
+ const entryReferenceUtil = new entry_reference_util_1.EntryReferenceUtil(persistenceService, entryTypeUtil, unionTypeUtil);
27
33
  const schemaRootTypeGeneratorService = new schema_root_type_generator_service_1.SchemaRootTypeGeneratorService();
28
- const inputTypeGeneratorService = new input_type_generator_service_1.InputTypeGeneratorService(entryReferenceUtil);
29
- const schemaAnalyzerService = new schema_analyzer_service_1.SchemaAnalyzerService(entryReferenceUtil);
30
- const entryReferenceResolverGeneratorService = new entry_reference_resolver_generator_1.EntryReferenceResolverGenerator(persistenceService);
31
- const mutationCreateResolverGenerator = new mutation_create_resolver_generator_1.MutationCreateResolverGenerator(persistenceService);
32
- const mutationDeleteResolverGenerator = new mutation_delete_resolver_generator_1.MutationDeleteResolverGenerator(persistenceService);
33
- const mutationUpdateResolverGenerator = new mutation_update_resolver_generator_1.MutationUpdateResolverGenerator(persistenceService);
34
+ const inputTypeGeneratorService = new input_type_generator_service_1.InputTypeGeneratorService(entryTypeUtil);
35
+ const schemaAnalyzerService = new schema_analyzer_service_1.SchemaAnalyzerService();
36
+ const mutationCreateResolverGenerator = new mutation_create_resolver_generator_1.MutationCreateResolverGenerator(persistenceService, entryReferenceUtil);
37
+ const mutationDeleteResolverGenerator = new mutation_delete_resolver_generator_1.MutationDeleteResolverGenerator(persistenceService, entryReferenceUtil);
38
+ const mutationUpdateResolverGenerator = new mutation_update_resolver_generator_1.MutationUpdateResolverGenerator(persistenceService, entryReferenceUtil);
34
39
  const queryAllResolverGenerator = new query_all_resolver_generator_1.QueryAllResolverGenerator(persistenceService);
35
40
  const queryByIdResolverGenerator = new query_by_id_resolver_generator_1.QueryByIdResolverGenerator(persistenceService);
36
41
  const queryCountAllResolverGenerator = new query_count_all_resolver_generator_1.QueryCountAllResolverGenerator(persistenceService);
37
42
  const queryTypeByIdResolverGenerator = new query_type_by_id_resolver_generator_1.QueryTypeByIdResolverGenerator(persistenceService);
38
- const unionTypeResolverGenerator = new union_type_resolver_generator_1.UnionTypeResolverGenerator(persistenceService, entryReferenceUtil);
39
- const unionValueResolverGenerator = new union_value_resolver_generator_1.UnionValueResolverGenerator(entryReferenceUtil);
43
+ const unionTypeResolverGenerator = new union_type_resolver_generator_1.UnionTypeResolverGenerator(persistenceService, entryTypeUtil);
44
+ const unionValueResolver = new union_value_resolver_1.UnionValueResolver(unionTypeUtil);
45
+ const entryReferenceResolver = new entry_reference_resolver_1.EntryReferenceResolver(persistenceService);
46
+ const fieldDefaultValueResolver = new field_default_value_resolver_1.FieldDefaultValueResolver(entryTypeUtil, unionValueResolver, entryReferenceResolver);
47
+ const objectTypeFieldDefaultValueResolverGenerator = new object_type_field_default_value_resolver_generator_1.ObjectTypeFieldDefaultValueResolverGenerator(fieldDefaultValueResolver);
40
48
  const queriesMutationsGeneratorService = new queries_mutations_generator_service_1.QueriesMutationsGeneratorService(queryAllResolverGenerator, queryByIdResolverGenerator, queryCountAllResolverGenerator, queryTypeByIdResolverGenerator, mutationCreateResolverGenerator, mutationUpdateResolverGenerator, mutationDeleteResolverGenerator);
41
- const schemaGeneratorService = new schema_generator_service_1.SchemaGeneratorService(queriesMutationsGeneratorService, schemaAnalyzerService, inputTypeGeneratorService, schemaRootTypeGeneratorService, entryReferenceResolverGeneratorService, unionTypeResolverGenerator, unionValueResolverGenerator, schemaValidator);
49
+ const schemaGeneratorService = new schema_generator_service_1.SchemaGeneratorService(queriesMutationsGeneratorService, schemaAnalyzerService, inputTypeGeneratorService, schemaRootTypeGeneratorService, unionTypeResolverGenerator, objectTypeFieldDefaultValueResolverGenerator, schemaValidator);
42
50
  const apolloConfigFactoryService = new apollo_config_factory_service_1.ApolloConfigFactoryService(schemaGeneratorService);
43
51
  exports.apiService = new api_service_1.ApiService(apolloConfigFactoryService, schemaGeneratorService);
44
52
  //# sourceMappingURL=container.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"container.js","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAC9C,2FAAoF;AACpF,yHAAkH;AAClH,yFAAkF;AAClF,uGAAgG;AAChG,+EAAyE;AACzE,qGAA6F;AAC7F,+GAAwG;AACxG,2EAAsE;AACtE,iFAA2E;AAC3E,yHAAkH;AAClH,yHAAkH;AAClH,yHAAkH;AAClH,6GAAsG;AACtG,iHAAyG;AACzG,yHAAiH;AACjH,2HAAkH;AAClH,iEAA4D;AAC5D,iHAA0G;AAC1G,sFAAgF;AAIhF,MAAM,kBAAkB,GAAG,IAAI,yCAAkB,EAAE,CAAA;AACnD,MAAM,eAAe,GAAG,IAAI,kCAAe,EAAE,CAAA;AAC7C,MAAM,kBAAkB,GAAG,IAAI,wCAAkB,EAAE,CAAA;AACnD,MAAM,8BAA8B,GAAG,IAAI,mEAA8B,EAAE,CAAA;AAE3E,MAAM,yBAAyB,GAAG,IAAI,wDAAyB,CAC7D,kBAAkB,CACnB,CAAA;AACD,MAAM,qBAAqB,GAAG,IAAI,+CAAqB,CAAC,kBAAkB,CAAC,CAAA;AAC3E,MAAM,sCAAsC,GAC1C,IAAI,oEAA+B,CAAC,kBAAkB,CAAC,CAAA;AACzD,MAAM,+BAA+B,GAAG,IAAI,oEAA+B,CACzE,kBAAkB,CACnB,CAAA;AACD,MAAM,+BAA+B,GAAG,IAAI,oEAA+B,CACzE,kBAAkB,CACnB,CAAA;AACD,MAAM,+BAA+B,GAAG,IAAI,oEAA+B,CACzE,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,kBAAkB,CACnB,CAAA;AACD,MAAM,2BAA2B,GAAG,IAAI,4DAA2B,CACjE,kBAAkB,CACnB,CAAA;AAED,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,sCAAsC,EACtC,0BAA0B,EAC1B,2BAA2B,EAC3B,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"}
1
+ {"version":3,"file":"container.js","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAC9C,2FAAoF;AACpF,yFAAkF;AAClF,uGAAgG;AAChG,+EAAyE;AACzE,qGAA6F;AAC7F,+GAAwG;AACxG,2EAAsE;AACtE,iFAA2E;AAC3E,yHAAkH;AAClH,yHAAkH;AAClH,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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,10 @@
1
+ import { FieldResolver, ResolvedEntryData, FieldResolverContext } from './fieldResolver';
2
+ import { GraphQLFieldResolver } from 'graphql/type/definition';
3
+ import { PersistenceService } from '../../persistence/persistence.service';
4
+ import { EntryData } from '@commitspark/git-adapter';
5
+ export declare class EntryReferenceResolver implements FieldResolver<any> {
6
+ private readonly persistence;
7
+ resolve: GraphQLFieldResolver<any, FieldResolverContext, any, Promise<ResolvedEntryData<EntryData | EntryData[] | null>>>;
8
+ constructor(persistence: PersistenceService);
9
+ private resolveFieldValue;
10
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntryReferenceResolver = void 0;
4
+ class EntryReferenceResolver {
5
+ constructor(persistence) {
6
+ this.persistence = persistence;
7
+ this.resolve = (fieldValue, args, context, info) => this.resolveFieldValue(fieldValue, args, context, info, info.returnType);
8
+ }
9
+ async resolveFieldValue(fieldValue, args, context, info, currentType) {
10
+ const entry = await this.persistence.findById(context.gitAdapter, context.getCurrentRef(), fieldValue.id);
11
+ return Object.assign(Object.assign({}, entry.data), { id: entry.id });
12
+ }
13
+ }
14
+ exports.EntryReferenceResolver = EntryReferenceResolver;
15
+ //# 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;IAEO,KAAK,CAAC,iBAAiB,CAC7B,UAAe,EACf,IAAS,EACT,OAA6B,EAC7B,IAAwB,EACxB,WAA8B;QAE9B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAC3C,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,aAAa,EAAE,EACvB,UAAU,CAAC,EAAE,CACd,CAAA;QAED,uCAAY,KAAK,CAAC,IAAI,KAAE,EAAE,EAAE,KAAK,CAAC,EAAE,IAAE;IACxC,CAAC;CACF;AAjCD,wDAiCC"}
@@ -0,0 +1,14 @@
1
+ import { FieldResolver, ResolvedEntryData, FieldResolverContext } from './fieldResolver';
2
+ import { EntryData } from '@commitspark/git-adapter';
3
+ import { GraphQLFieldResolver } from 'graphql/type/definition';
4
+ import { EntryTypeUtil } from '../schema-utils/entry-type-util';
5
+ import { UnionValueResolver } from './union-value-resolver';
6
+ import { EntryReferenceResolver } from './entry-reference-resolver';
7
+ export declare class FieldDefaultValueResolver implements FieldResolver<any> {
8
+ private readonly entryTypeUtil;
9
+ private readonly unionValueResolver;
10
+ private readonly entryReferenceResolver;
11
+ resolve: GraphQLFieldResolver<any, FieldResolverContext, any, Promise<ResolvedEntryData<EntryData | EntryData[] | null>>>;
12
+ constructor(entryTypeUtil: EntryTypeUtil, unionValueResolver: UnionValueResolver, entryReferenceResolver: EntryReferenceResolver);
13
+ private resolveFieldValue;
14
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldDefaultValueResolver = void 0;
4
+ const graphql_1 = require("graphql");
5
+ class FieldDefaultValueResolver {
6
+ constructor(entryTypeUtil, unionValueResolver, entryReferenceResolver) {
7
+ this.entryTypeUtil = entryTypeUtil;
8
+ this.unionValueResolver = unionValueResolver;
9
+ this.entryReferenceResolver = entryReferenceResolver;
10
+ this.resolve = (fieldValue, args, context, info) => this.resolveFieldValue(fieldValue, args, context, info, info.returnType, false);
11
+ }
12
+ resolveFieldValue(fieldValue, args, context, info, currentType, hasNonNullParent) {
13
+ if ((0, graphql_1.isNonNullType)(currentType)) {
14
+ return this.resolveFieldValue(fieldValue, args, {
15
+ gitAdapter: context.gitAdapter,
16
+ getCurrentRef: context.getCurrentRef,
17
+ }, info, currentType.ofType, true);
18
+ }
19
+ else if ((0, graphql_1.isListType)(currentType)) {
20
+ if (fieldValue === undefined || fieldValue === null) {
21
+ if (hasNonNullParent) {
22
+ return new Promise((resolve) => resolve([]));
23
+ }
24
+ else {
25
+ return new Promise((resolve) => resolve(null));
26
+ }
27
+ }
28
+ if (!Array.isArray(fieldValue)) {
29
+ throw new Error(`Expected array while resolving value for field "${info.fieldName}".`);
30
+ }
31
+ const resultPromises = [];
32
+ for (const item of fieldValue) {
33
+ const resultPromise = this.resolveFieldValue(item, args, {
34
+ gitAdapter: context.gitAdapter,
35
+ getCurrentRef: context.getCurrentRef,
36
+ }, info, currentType.ofType, hasNonNullParent);
37
+ resultPromises.push(resultPromise);
38
+ }
39
+ return Promise.all(resultPromises);
40
+ }
41
+ else if ((0, graphql_1.isUnionType)(currentType)) {
42
+ if (fieldValue === undefined || fieldValue === null) {
43
+ if (hasNonNullParent) {
44
+ throw new Error(`Cannot generate a default value for NonNull field "${info.parentType.name}.${info.fieldName}" because it is a union field of type "${info.returnType.ofType.name}".`);
45
+ }
46
+ else {
47
+ return new Promise((resolve) => resolve(null));
48
+ }
49
+ }
50
+ if (this.entryTypeUtil.buildsOnTypeWithEntryDirective(currentType)) {
51
+ return this.entryReferenceResolver.resolve(fieldValue, args, context, info);
52
+ }
53
+ return this.unionValueResolver.resolve(fieldValue, args, context, info);
54
+ }
55
+ else if ((0, graphql_1.isObjectType)(currentType)) {
56
+ if (fieldValue === undefined || fieldValue === null) {
57
+ if (hasNonNullParent) {
58
+ throw new Error(`Cannot generate a default value for NonNull field "${info.fieldName}" of type "${info.parentType.name}".`);
59
+ }
60
+ else {
61
+ return new Promise((resolve) => resolve(null));
62
+ }
63
+ }
64
+ if (this.entryTypeUtil.hasEntryDirective(currentType)) {
65
+ return this.entryReferenceResolver.resolve(fieldValue, args, context, info);
66
+ }
67
+ return fieldValue;
68
+ }
69
+ return fieldValue;
70
+ }
71
+ }
72
+ exports.FieldDefaultValueResolver = FieldDefaultValueResolver;
73
+ //# sourceMappingURL=field-default-value-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-default-value-resolver.js","sourceRoot":"","sources":["../../../src/graphql/field-resolver/field-default-value-resolver.ts"],"names":[],"mappings":";;;AAWA,qCAOgB;AAKhB,MAAa,yBAAyB;IAQpC,YACmB,aAA4B,EAC5B,kBAAsC,EACtC,sBAA8C;QAF9C,kBAAa,GAAb,aAAa,CAAe;QAC5B,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,2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;qBAAM;oBACL,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;iBAC/C;aACF;YAED,IAAI,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE;gBACrD,OAAO,IAAI,CAAC,sBAAsB,CAAC,OAAO,CACxC,UAAU,EACV,IAAI,EACJ,OAAO,EACP,IAAI,CACL,CAAA;aACF;YAED,OAAO,UAAU,CAAA;SAClB;QAED,OAAO,UAAU,CAAA;IACnB,CAAC;CACF;AAlID,8DAkIC"}
@@ -0,0 +1,11 @@
1
+ import { GraphQLFieldResolver } from 'graphql/type/definition';
2
+ import { EntryData } from '@commitspark/git-adapter';
3
+ import { GitAdapter } from '@commitspark/git-adapter';
4
+ export interface FieldResolverContext {
5
+ gitAdapter: GitAdapter;
6
+ getCurrentRef(): string;
7
+ }
8
+ export interface FieldResolver<TSource, TContext = FieldResolverContext, TArgs = any, TResult = Promise<ResolvedEntryData<EntryData | EntryData[] | null>>> {
9
+ resolve: GraphQLFieldResolver<TSource, TContext, TArgs, TResult>;
10
+ }
11
+ export type ResolvedEntryData<T> = T | Array<ResolvedEntryData<T>>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=fieldResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fieldResolver.js","sourceRoot":"","sources":["../../../src/graphql/field-resolver/fieldResolver.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import { GraphQLFieldResolver } from 'graphql/type/definition';
2
+ import { EntryData } from '@commitspark/git-adapter';
3
+ import { FieldResolver, ResolvedEntryData, FieldResolverContext } from './fieldResolver';
4
+ import { UnionTypeUtil } from '../schema-utils/union-type-util';
5
+ export declare class UnionValueResolver implements FieldResolver<any> {
6
+ private readonly unionTypeUtil;
7
+ resolve: GraphQLFieldResolver<any, FieldResolverContext, any, Promise<ResolvedEntryData<EntryData | EntryData[] | null>>>;
8
+ constructor(unionTypeUtil: UnionTypeUtil);
9
+ private resolveFieldValue;
10
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnionValueResolver = void 0;
4
+ class UnionValueResolver {
5
+ constructor(unionTypeUtil) {
6
+ this.unionTypeUtil = unionTypeUtil;
7
+ this.resolve = (fieldValue, args, context, info) => this.resolveFieldValue(fieldValue);
8
+ }
9
+ resolveFieldValue(fieldValue) {
10
+ const typeName = this.unionTypeUtil.getUnionTypeNameFromFieldValue(fieldValue);
11
+ const unionValue = this.unionTypeUtil.getUnionValue(fieldValue);
12
+ const res = Object.assign(Object.assign({}, unionValue), { __typename: typeName });
13
+ return new Promise((resolve) => resolve(res));
14
+ }
15
+ }
16
+ exports.UnionValueResolver = UnionValueResolver;
17
+ //# sourceMappingURL=union-value-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"union-value-resolver.js","sourceRoot":"","sources":["../../../src/graphql/field-resolver/union-value-resolver.ts"],"names":[],"mappings":";;;AASA,MAAa,kBAAkB;IAQ7B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QACvD,IAAI,CAAC,OAAO,GAAG,CACb,UAAU,EACV,IAAI,EACJ,OAAO,EACP,IAAI,EACwD,EAAE,CAC9D,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAA;IACtC,CAAC;IAEO,iBAAiB,CACvB,UAAe;QAEf,MAAM,QAAQ,GACZ,IAAI,CAAC,aAAa,CAAC,8BAA8B,CAAC,UAAU,CAAC,CAAA;QAC/D,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;QAM/D,MAAM,GAAG,mCACJ,UAAU,KACb,UAAU,EAAE,QAAQ,GACrB,CAAA;QAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;IAC/C,CAAC;CACF;AApCD,gDAoCC"}
@@ -1,9 +1,9 @@
1
1
  import { GraphQLNullableType, GraphQLObjectType, GraphQLUnionType } from 'graphql';
2
2
  import { ISchemaAnalyzerResult } from './schema-analyzer.service';
3
- import { EntryReferenceUtil } from './schema-utils/entry-reference-util';
3
+ import { EntryTypeUtil } from './schema-utils/entry-type-util';
4
4
  export declare class InputTypeGeneratorService {
5
- private readonly entryReferenceUtil;
6
- constructor(entryReferenceUtil: EntryReferenceUtil);
5
+ private readonly entryTypeUtil;
6
+ constructor(entryTypeUtil: EntryTypeUtil);
7
7
  generateFieldInputTypeString(type: GraphQLNullableType): string;
8
8
  generateIdInputTypeStrings(schemaAnalyzerResult: ISchemaAnalyzerResult): string[];
9
9
  generateObjectInputTypeStrings(objectTypes: GraphQLObjectType[]): string[];