@contember/engine-content-api 2.2.0-alpha.19 → 2.2.0-alpha.20

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 (273) hide show
  1. package/CLAUDE.md +12 -7
  2. package/dist/development/index.cjs +23 -0
  3. package/dist/development/index.cjs.map +1 -1
  4. package/dist/development/index.js +25 -2
  5. package/dist/development/index.js.map +1 -1
  6. package/dist/development/src/ExecutionContainer.cjs +4 -3
  7. package/dist/development/src/ExecutionContainer.cjs.map +1 -1
  8. package/dist/development/src/ExecutionContainer.js +4 -3
  9. package/dist/development/src/ExecutionContainer.js.map +1 -1
  10. package/dist/development/src/acl/Authorizator.cjs +6 -1
  11. package/dist/development/src/acl/Authorizator.cjs.map +1 -1
  12. package/dist/development/src/acl/Authorizator.js +6 -1
  13. package/dist/development/src/acl/Authorizator.js.map +1 -1
  14. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +1 -1
  15. package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +1 -1
  16. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +1 -1
  17. package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +1 -1
  18. package/dist/development/src/introspection/introspection.schema.cjs +2 -2
  19. package/dist/development/src/introspection/introspection.schema.cjs.map +1 -1
  20. package/dist/development/src/introspection/introspection.schema.js +2 -2
  21. package/dist/development/src/introspection/introspection.schema.js.map +1 -1
  22. package/dist/development/src/mapper/select/SelectHydrator.cjs +56 -15
  23. package/dist/development/src/mapper/select/SelectHydrator.cjs.map +1 -1
  24. package/dist/development/src/mapper/select/SelectHydrator.js +56 -15
  25. package/dist/development/src/mapper/select/SelectHydrator.js.map +1 -1
  26. package/dist/development/src/resolvers/GraphQlQueryAstFactory.cjs.map +1 -1
  27. package/dist/development/src/resolvers/GraphQlQueryAstFactory.js.map +1 -1
  28. package/dist/development/src/resolvers/MutationResolver.cjs +17 -39
  29. package/dist/development/src/resolvers/MutationResolver.cjs.map +1 -1
  30. package/dist/development/src/resolvers/MutationResolver.js +18 -40
  31. package/dist/development/src/resolvers/MutationResolver.js.map +1 -1
  32. package/dist/development/src/resolvers/ReadHelpers.cjs +4 -5
  33. package/dist/development/src/resolvers/ReadHelpers.cjs.map +1 -1
  34. package/dist/development/src/resolvers/ReadHelpers.js +4 -5
  35. package/dist/development/src/resolvers/ReadHelpers.js.map +1 -1
  36. package/dist/development/src/resolvers/ReadResolver.cjs +8 -17
  37. package/dist/development/src/resolvers/ReadResolver.cjs.map +1 -1
  38. package/dist/development/src/resolvers/ReadResolver.js +8 -17
  39. package/dist/development/src/resolvers/ReadResolver.js.map +1 -1
  40. package/dist/development/src/schema/GraphQlSchemaBuilder.cjs +16 -6
  41. package/dist/development/src/schema/GraphQlSchemaBuilder.cjs.map +1 -1
  42. package/dist/development/src/schema/GraphQlSchemaBuilder.js +16 -6
  43. package/dist/development/src/schema/GraphQlSchemaBuilder.js.map +1 -1
  44. package/dist/development/src/schema/MutationProvider.cjs +21 -8
  45. package/dist/development/src/schema/MutationProvider.cjs.map +1 -1
  46. package/dist/development/src/schema/MutationProvider.js +21 -8
  47. package/dist/development/src/schema/MutationProvider.js.map +1 -1
  48. package/dist/development/src/schema/QueryProvider.cjs +6 -6
  49. package/dist/development/src/schema/QueryProvider.cjs.map +1 -1
  50. package/dist/development/src/schema/QueryProvider.js +6 -6
  51. package/dist/development/src/schema/QueryProvider.js.map +1 -1
  52. package/dist/development/src/schema-json/GraphQLJsBridge.cjs +108 -0
  53. package/dist/development/src/schema-json/GraphQLJsBridge.cjs.map +1 -0
  54. package/dist/development/src/schema-json/GraphQLJsBridge.js +108 -0
  55. package/dist/development/src/schema-json/GraphQLJsBridge.js.map +1 -0
  56. package/dist/development/src/schema-json/JsonColumnTypes.cjs +102 -0
  57. package/dist/development/src/schema-json/JsonColumnTypes.cjs.map +1 -0
  58. package/dist/development/src/schema-json/JsonColumnTypes.js +102 -0
  59. package/dist/development/src/schema-json/JsonColumnTypes.js.map +1 -0
  60. package/dist/development/src/schema-json/JsonContentSchemaBuilder.cjs +418 -0
  61. package/dist/development/src/schema-json/JsonContentSchemaBuilder.cjs.map +1 -0
  62. package/dist/development/src/schema-json/JsonContentSchemaBuilder.js +418 -0
  63. package/dist/development/src/schema-json/JsonContentSchemaBuilder.js.map +1 -0
  64. package/dist/development/src/schema-json/JsonContentSchemaShared.cjs +18 -0
  65. package/dist/development/src/schema-json/JsonContentSchemaShared.cjs.map +1 -0
  66. package/dist/development/src/schema-json/JsonContentSchemaShared.js +18 -0
  67. package/dist/development/src/schema-json/JsonContentSchemaShared.js.map +1 -0
  68. package/dist/development/src/schema-json/JsonEntityTypes.cjs +206 -0
  69. package/dist/development/src/schema-json/JsonEntityTypes.cjs.map +1 -0
  70. package/dist/development/src/schema-json/JsonEntityTypes.js +206 -0
  71. package/dist/development/src/schema-json/JsonEntityTypes.js.map +1 -0
  72. package/dist/development/src/schema-json/JsonFilterTypes.cjs +152 -0
  73. package/dist/development/src/schema-json/JsonFilterTypes.cjs.map +1 -0
  74. package/dist/development/src/schema-json/JsonFilterTypes.js +152 -0
  75. package/dist/development/src/schema-json/JsonFilterTypes.js.map +1 -0
  76. package/dist/development/src/schema-json/JsonInputTypes.cjs +256 -0
  77. package/dist/development/src/schema-json/JsonInputTypes.cjs.map +1 -0
  78. package/dist/development/src/schema-json/JsonInputTypes.js +256 -0
  79. package/dist/development/src/schema-json/JsonInputTypes.js.map +1 -0
  80. package/dist/development/src/schema-json/JsonIntrospectionExtension.cjs +36 -0
  81. package/dist/development/src/schema-json/JsonIntrospectionExtension.cjs.map +1 -0
  82. package/dist/development/src/schema-json/JsonIntrospectionExtension.js +36 -0
  83. package/dist/development/src/schema-json/JsonIntrospectionExtension.js.map +1 -0
  84. package/dist/development/src/schema-json/JsonQueryAstFactory.cjs +107 -0
  85. package/dist/development/src/schema-json/JsonQueryAstFactory.cjs.map +1 -0
  86. package/dist/development/src/schema-json/JsonQueryAstFactory.js +107 -0
  87. package/dist/development/src/schema-json/JsonQueryAstFactory.js.map +1 -0
  88. package/dist/development/src/schema-json/JsonTypeRegistry.cjs +230 -0
  89. package/dist/development/src/schema-json/JsonTypeRegistry.cjs.map +1 -0
  90. package/dist/development/src/schema-json/JsonTypeRegistry.js +230 -0
  91. package/dist/development/src/schema-json/JsonTypeRegistry.js.map +1 -0
  92. package/dist/development/src/utils/ResolveInfoUtils.cjs.map +1 -1
  93. package/dist/development/src/utils/ResolveInfoUtils.js.map +1 -1
  94. package/dist/development/src/utils/uniqueWhereFields.cjs +10 -0
  95. package/dist/development/src/utils/uniqueWhereFields.cjs.map +1 -1
  96. package/dist/development/src/utils/uniqueWhereFields.js +10 -0
  97. package/dist/development/src/utils/uniqueWhereFields.js.map +1 -1
  98. package/dist/production/index.cjs +23 -0
  99. package/dist/production/index.cjs.map +1 -1
  100. package/dist/production/index.js +25 -2
  101. package/dist/production/index.js.map +1 -1
  102. package/dist/production/src/ExecutionContainer.cjs +4 -3
  103. package/dist/production/src/ExecutionContainer.cjs.map +1 -1
  104. package/dist/production/src/ExecutionContainer.js +4 -3
  105. package/dist/production/src/ExecutionContainer.js.map +1 -1
  106. package/dist/production/src/acl/Authorizator.cjs +6 -1
  107. package/dist/production/src/acl/Authorizator.cjs.map +1 -1
  108. package/dist/production/src/acl/Authorizator.js +6 -1
  109. package/dist/production/src/acl/Authorizator.js.map +1 -1
  110. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +1 -1
  111. package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +1 -1
  112. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +1 -1
  113. package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +1 -1
  114. package/dist/production/src/introspection/introspection.schema.cjs +2 -2
  115. package/dist/production/src/introspection/introspection.schema.cjs.map +1 -1
  116. package/dist/production/src/introspection/introspection.schema.js +2 -2
  117. package/dist/production/src/introspection/introspection.schema.js.map +1 -1
  118. package/dist/production/src/mapper/select/SelectHydrator.cjs +56 -15
  119. package/dist/production/src/mapper/select/SelectHydrator.cjs.map +1 -1
  120. package/dist/production/src/mapper/select/SelectHydrator.js +56 -15
  121. package/dist/production/src/mapper/select/SelectHydrator.js.map +1 -1
  122. package/dist/production/src/resolvers/GraphQlQueryAstFactory.cjs.map +1 -1
  123. package/dist/production/src/resolvers/GraphQlQueryAstFactory.js.map +1 -1
  124. package/dist/production/src/resolvers/MutationResolver.cjs +17 -39
  125. package/dist/production/src/resolvers/MutationResolver.cjs.map +1 -1
  126. package/dist/production/src/resolvers/MutationResolver.js +18 -40
  127. package/dist/production/src/resolvers/MutationResolver.js.map +1 -1
  128. package/dist/production/src/resolvers/ReadHelpers.cjs +4 -5
  129. package/dist/production/src/resolvers/ReadHelpers.cjs.map +1 -1
  130. package/dist/production/src/resolvers/ReadHelpers.js +4 -5
  131. package/dist/production/src/resolvers/ReadHelpers.js.map +1 -1
  132. package/dist/production/src/resolvers/ReadResolver.cjs +8 -17
  133. package/dist/production/src/resolvers/ReadResolver.cjs.map +1 -1
  134. package/dist/production/src/resolvers/ReadResolver.js +8 -17
  135. package/dist/production/src/resolvers/ReadResolver.js.map +1 -1
  136. package/dist/production/src/schema/GraphQlSchemaBuilder.cjs +16 -6
  137. package/dist/production/src/schema/GraphQlSchemaBuilder.cjs.map +1 -1
  138. package/dist/production/src/schema/GraphQlSchemaBuilder.js +16 -6
  139. package/dist/production/src/schema/GraphQlSchemaBuilder.js.map +1 -1
  140. package/dist/production/src/schema/MutationProvider.cjs +21 -8
  141. package/dist/production/src/schema/MutationProvider.cjs.map +1 -1
  142. package/dist/production/src/schema/MutationProvider.js +21 -8
  143. package/dist/production/src/schema/MutationProvider.js.map +1 -1
  144. package/dist/production/src/schema/QueryProvider.cjs +6 -6
  145. package/dist/production/src/schema/QueryProvider.cjs.map +1 -1
  146. package/dist/production/src/schema/QueryProvider.js +6 -6
  147. package/dist/production/src/schema/QueryProvider.js.map +1 -1
  148. package/dist/production/src/schema-json/GraphQLJsBridge.cjs +108 -0
  149. package/dist/production/src/schema-json/GraphQLJsBridge.cjs.map +1 -0
  150. package/dist/production/src/schema-json/GraphQLJsBridge.js +108 -0
  151. package/dist/production/src/schema-json/GraphQLJsBridge.js.map +1 -0
  152. package/dist/production/src/schema-json/JsonColumnTypes.cjs +102 -0
  153. package/dist/production/src/schema-json/JsonColumnTypes.cjs.map +1 -0
  154. package/dist/production/src/schema-json/JsonColumnTypes.js +102 -0
  155. package/dist/production/src/schema-json/JsonColumnTypes.js.map +1 -0
  156. package/dist/production/src/schema-json/JsonContentSchemaBuilder.cjs +418 -0
  157. package/dist/production/src/schema-json/JsonContentSchemaBuilder.cjs.map +1 -0
  158. package/dist/production/src/schema-json/JsonContentSchemaBuilder.js +418 -0
  159. package/dist/production/src/schema-json/JsonContentSchemaBuilder.js.map +1 -0
  160. package/dist/production/src/schema-json/JsonContentSchemaShared.cjs +18 -0
  161. package/dist/production/src/schema-json/JsonContentSchemaShared.cjs.map +1 -0
  162. package/dist/production/src/schema-json/JsonContentSchemaShared.js +18 -0
  163. package/dist/production/src/schema-json/JsonContentSchemaShared.js.map +1 -0
  164. package/dist/production/src/schema-json/JsonEntityTypes.cjs +206 -0
  165. package/dist/production/src/schema-json/JsonEntityTypes.cjs.map +1 -0
  166. package/dist/production/src/schema-json/JsonEntityTypes.js +206 -0
  167. package/dist/production/src/schema-json/JsonEntityTypes.js.map +1 -0
  168. package/dist/production/src/schema-json/JsonFilterTypes.cjs +152 -0
  169. package/dist/production/src/schema-json/JsonFilterTypes.cjs.map +1 -0
  170. package/dist/production/src/schema-json/JsonFilterTypes.js +152 -0
  171. package/dist/production/src/schema-json/JsonFilterTypes.js.map +1 -0
  172. package/dist/production/src/schema-json/JsonInputTypes.cjs +256 -0
  173. package/dist/production/src/schema-json/JsonInputTypes.cjs.map +1 -0
  174. package/dist/production/src/schema-json/JsonInputTypes.js +256 -0
  175. package/dist/production/src/schema-json/JsonInputTypes.js.map +1 -0
  176. package/dist/production/src/schema-json/JsonIntrospectionExtension.cjs +36 -0
  177. package/dist/production/src/schema-json/JsonIntrospectionExtension.cjs.map +1 -0
  178. package/dist/production/src/schema-json/JsonIntrospectionExtension.js +36 -0
  179. package/dist/production/src/schema-json/JsonIntrospectionExtension.js.map +1 -0
  180. package/dist/production/src/schema-json/JsonQueryAstFactory.cjs +107 -0
  181. package/dist/production/src/schema-json/JsonQueryAstFactory.cjs.map +1 -0
  182. package/dist/production/src/schema-json/JsonQueryAstFactory.js +107 -0
  183. package/dist/production/src/schema-json/JsonQueryAstFactory.js.map +1 -0
  184. package/dist/production/src/schema-json/JsonTypeRegistry.cjs +230 -0
  185. package/dist/production/src/schema-json/JsonTypeRegistry.cjs.map +1 -0
  186. package/dist/production/src/schema-json/JsonTypeRegistry.js +230 -0
  187. package/dist/production/src/schema-json/JsonTypeRegistry.js.map +1 -0
  188. package/dist/production/src/utils/ResolveInfoUtils.cjs.map +1 -1
  189. package/dist/production/src/utils/ResolveInfoUtils.js.map +1 -1
  190. package/dist/production/src/utils/uniqueWhereFields.cjs +10 -0
  191. package/dist/production/src/utils/uniqueWhereFields.cjs.map +1 -1
  192. package/dist/production/src/utils/uniqueWhereFields.js +10 -0
  193. package/dist/production/src/utils/uniqueWhereFields.js.map +1 -1
  194. package/dist/tests/src/test.d.ts +10 -2
  195. package/dist/tests/src/test.d.ts.map +1 -1
  196. package/dist/tests/src/testGraphql.d.ts +18 -5
  197. package/dist/tests/src/testGraphql.d.ts.map +1 -1
  198. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  199. package/dist/types/ExecutionContainer.d.ts +1 -0
  200. package/dist/types/ExecutionContainer.d.ts.map +1 -1
  201. package/dist/types/acl/Authorizator.d.ts.map +1 -1
  202. package/dist/types/index.d.ts +1 -0
  203. package/dist/types/index.d.ts.map +1 -1
  204. package/dist/types/mapper/select/SelectHydrator.d.ts +4 -1
  205. package/dist/types/mapper/select/SelectHydrator.d.ts.map +1 -1
  206. package/dist/types/resolvers/GraphQlQueryAstFactory.d.ts +4 -3
  207. package/dist/types/resolvers/GraphQlQueryAstFactory.d.ts.map +1 -1
  208. package/dist/types/resolvers/MutationResolver.d.ts +14 -11
  209. package/dist/types/resolvers/MutationResolver.d.ts.map +1 -1
  210. package/dist/types/resolvers/ReadHelpers.d.ts +1 -2
  211. package/dist/types/resolvers/ReadHelpers.d.ts.map +1 -1
  212. package/dist/types/resolvers/ReadResolver.d.ts +8 -10
  213. package/dist/types/resolvers/ReadResolver.d.ts.map +1 -1
  214. package/dist/types/schema/GraphQlSchemaBuilder.d.ts.map +1 -1
  215. package/dist/types/schema/MutationProvider.d.ts.map +1 -1
  216. package/dist/types/schema-json/GraphQLJsBridge.d.ts +12 -0
  217. package/dist/types/schema-json/GraphQLJsBridge.d.ts.map +1 -0
  218. package/dist/types/schema-json/JsonColumnTypes.d.ts +23 -0
  219. package/dist/types/schema-json/JsonColumnTypes.d.ts.map +1 -0
  220. package/dist/types/schema-json/JsonContentSchemaBuilder.d.ts +56 -0
  221. package/dist/types/schema-json/JsonContentSchemaBuilder.d.ts.map +1 -0
  222. package/dist/types/schema-json/JsonContentSchemaShared.d.ts +19 -0
  223. package/dist/types/schema-json/JsonContentSchemaShared.d.ts.map +1 -0
  224. package/dist/types/schema-json/JsonEntityTypes.d.ts +29 -0
  225. package/dist/types/schema-json/JsonEntityTypes.d.ts.map +1 -0
  226. package/dist/types/schema-json/JsonFilterTypes.d.ts +21 -0
  227. package/dist/types/schema-json/JsonFilterTypes.d.ts.map +1 -0
  228. package/dist/types/schema-json/JsonInputTypes.d.ts +36 -0
  229. package/dist/types/schema-json/JsonInputTypes.d.ts.map +1 -0
  230. package/dist/types/schema-json/JsonIntrospectionExtension.d.ts +5 -0
  231. package/dist/types/schema-json/JsonIntrospectionExtension.d.ts.map +1 -0
  232. package/dist/types/schema-json/JsonQueryAstFactory.d.ts +18 -0
  233. package/dist/types/schema-json/JsonQueryAstFactory.d.ts.map +1 -0
  234. package/dist/types/schema-json/JsonTypeRegistry.d.ts +57 -0
  235. package/dist/types/schema-json/JsonTypeRegistry.d.ts.map +1 -0
  236. package/dist/types/schema-json/index.d.ts +7 -0
  237. package/dist/types/schema-json/index.d.ts.map +1 -0
  238. package/dist/types/tsconfig.tsbuildinfo +1 -1
  239. package/dist/types/utils/ResolveInfoUtils.d.ts +4 -2
  240. package/dist/types/utils/ResolveInfoUtils.d.ts.map +1 -1
  241. package/dist/types/utils/uniqueWhereFields.d.ts.map +1 -1
  242. package/package.json +11 -10
  243. package/src/ExecutionContainer.ts +5 -3
  244. package/src/acl/Authorizator.ts +7 -1
  245. package/src/index.ts +1 -0
  246. package/src/mapper/select/SelectHydrator.ts +72 -17
  247. package/src/resolvers/GraphQlQueryAstFactory.ts +2 -2
  248. package/src/resolvers/MutationResolver.ts +22 -45
  249. package/src/resolvers/ReadHelpers.ts +1 -4
  250. package/src/resolvers/ReadResolver.ts +7 -18
  251. package/src/schema/GraphQlSchemaBuilder.ts +18 -7
  252. package/src/schema/MutationProvider.ts +21 -8
  253. package/src/schema/QueryProvider.ts +6 -6
  254. package/src/schema-json/GraphQLJsBridge.ts +142 -0
  255. package/src/schema-json/JsonColumnTypes.ts +116 -0
  256. package/src/schema-json/JsonContentSchemaBuilder.ts +501 -0
  257. package/src/schema-json/JsonContentSchemaShared.ts +19 -0
  258. package/src/schema-json/JsonEntityTypes.ts +237 -0
  259. package/src/schema-json/JsonFilterTypes.ts +159 -0
  260. package/src/schema-json/JsonInputTypes.ts +305 -0
  261. package/src/schema-json/JsonIntrospectionExtension.ts +37 -0
  262. package/src/schema-json/JsonQueryAstFactory.ts +128 -0
  263. package/src/schema-json/JsonTypeRegistry.ts +286 -0
  264. package/src/schema-json/index.ts +6 -0
  265. package/src/tsconfig.json +1 -0
  266. package/src/utils/ResolveInfoUtils.ts +2 -2
  267. package/src/utils/uniqueWhereFields.ts +14 -0
  268. package/tests/cases/integration/graphQlRequests/insert/memoryBudget.test.ts +2 -3
  269. package/tests/cases/integration/graphQlRequests/query/graphqlFeatures/alias.test.ts +44 -1
  270. package/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.ts +25 -29
  271. package/tests/src/test.ts +44 -10
  272. package/tests/src/testGraphql.ts +43 -20
  273. package/tests/tsconfig.json +1 -0
@@ -0,0 +1,501 @@
1
+ import { Acl, Input, Model, Result } from '@contember/schema'
2
+ import { introspectionTypes, ResolveInfo, ResolverFn, ResolverMap, ScalarMap, Schema, Type } from '@contember/graphql-json'
3
+ import { Authorizator } from '../acl/index.js'
4
+ import { Context } from '../types.js'
5
+ import { GqlTypeName } from '../schema/utils.js'
6
+ import { EntityInputType } from '../schema/mutations/index.js'
7
+ import { ExtensionKey, Operation, OperationMeta } from '../schema/OperationExtension.js'
8
+ import { mutationResultQueryAstFilter, TransactionOptions, transactionQueryAstFilter } from '../resolvers/MutationResolver.js'
9
+ import { ImplementationException } from '../exception.js'
10
+ import { JsonContentSchemaShared } from './JsonContentSchemaShared.js'
11
+ import { JsonColumnTypes } from './JsonColumnTypes.js'
12
+ import { JsonFilterTypes } from './JsonFilterTypes.js'
13
+ import { aliasAwareResolver, JsonEntityTypes } from './JsonEntityTypes.js'
14
+ import { JsonInputTypes } from './JsonInputTypes.js'
15
+ import { JsonQueryAstFactory } from './JsonQueryAstFactory.js'
16
+ import {
17
+ JsonOutputField,
18
+ JsonTypeRegistry,
19
+ listOfNonNullRef,
20
+ namedRef,
21
+ nonNullListOfNonNullListOfNonNullRef,
22
+ nonNullListOfNonNullRef,
23
+ nonNullRef,
24
+ } from './JsonTypeRegistry.js'
25
+
26
+ /** Fields and types merged into the content schema, e.g. the `schema` introspection query. */
27
+ export interface JsonSchemaExtension {
28
+ types: Record<string, Type>
29
+ /** Types the schema includes even when no field reaches them, e.g. interface implementations (graphql-js `types`). */
30
+ includedTypes?: readonly string[]
31
+ queries?: Record<string, JsonOutputField>
32
+ mutations?: Record<string, JsonOutputField>
33
+ resolvers?: ResolverMap<Context>
34
+ scalars?: ScalarMap
35
+ }
36
+
37
+ /** Coerces the field arguments without walking the selection, which may contain unions. */
38
+ const argumentsOnly = (node: unknown, path: string[]): boolean => path.length === 0
39
+
40
+ export interface JsonContentSchema {
41
+ schema: Schema
42
+ /** Looked up in order: the resolvers of this schema's extensions, then the ones all schemas of the model share. */
43
+ resolvers: readonly ResolverMap<Context>[]
44
+ scalars: ScalarMap
45
+ }
46
+
47
+ type RootResolve = (context: Context, info: ResolveInfo) => Promise<unknown>
48
+
49
+ // Resolvers are created by module-level functions, so they retain only the model and the shared AST factory,
50
+ // never a builder with its per-role state.
51
+
52
+ /** Root fields are also nested in `transaction`, where the parent already holds the result. */
53
+ const createRootResolver = (timerPrefix: string, resolve: RootResolve): ResolverFn<unknown, Context> => (parent, args, context, info) =>
54
+ context.timer(`${timerPrefix}.${info.fieldName}`, () => {
55
+ if (parent) {
56
+ return aliasAwareResolver(parent, args, context, info)
57
+ }
58
+ return resolve(context, info)
59
+ })
60
+
61
+ const createQueryResolvers = (entity: Model.Entity, astFactory: JsonQueryAstFactory) => ({
62
+ get: createRootResolver(
63
+ 'GraphQL.query',
64
+ (context, info) => context.executionContainer.readResolver.resolveGetQuery(entity, astFactory.create(info)),
65
+ ),
66
+ list: createRootResolver(
67
+ 'GraphQL.query',
68
+ (context, info) => context.executionContainer.readResolver.resolveListQuery(entity, astFactory.create(info)),
69
+ ),
70
+ paginate: createRootResolver(
71
+ 'GraphQL.query',
72
+ (context, info) => context.executionContainer.readResolver.resolvePaginationQuery(entity, astFactory.create(info)),
73
+ ),
74
+ })
75
+
76
+ const createValidationResolvers = (
77
+ entity: Model.Entity,
78
+ astFactory: JsonQueryAstFactory,
79
+ ): Record<'create' | 'update', ResolverFn<unknown, Context>> => ({
80
+ create: (parent, args, context, info) =>
81
+ context.timer(
82
+ `GraphQL.query.${info.fieldName}`,
83
+ () => context.executionContainer.validationResolver.validateCreate(entity, astFactory.create<Input.CreateInput>(info, argumentsOnly).args),
84
+ ),
85
+ update: (parent, args, context, info) =>
86
+ context.timer(
87
+ `GraphQL.query.${info.fieldName}`,
88
+ () => context.executionContainer.validationResolver.validateUpdate(entity, astFactory.create<Input.UpdateInput>(info, argumentsOnly).args),
89
+ ),
90
+ })
91
+
92
+ const createMutationResolvers = (entity: Model.Entity, astFactory: JsonQueryAstFactory) => {
93
+ const createAst = (info: ResolveInfo) => astFactory.create(info, mutationResultQueryAstFilter)
94
+ return {
95
+ create: createRootResolver(
96
+ 'GraphQL.mutation',
97
+ (context, info) => context.executionContainer.mutationResolver.resolveCreate(entity, createAst(info)),
98
+ ),
99
+ delete: createRootResolver(
100
+ 'GraphQL.mutation',
101
+ (context, info) => context.executionContainer.mutationResolver.resolveDelete(entity, createAst(info)),
102
+ ),
103
+ update: createRootResolver(
104
+ 'GraphQL.mutation',
105
+ (context, info) => context.executionContainer.mutationResolver.resolveUpdate(entity, createAst(info)),
106
+ ),
107
+ upsert: createRootResolver(
108
+ 'GraphQL.mutation',
109
+ (context, info) => context.executionContainer.mutationResolver.resolveUpsert(entity, createAst(info)),
110
+ ),
111
+ }
112
+ }
113
+
114
+ const createSchemaResolvers = (
115
+ astFactory: JsonQueryAstFactory,
116
+ ): Record<'queryTransaction' | 'mutationTransaction' | 'mutationQuery' | 'refreshView' | 'info', ResolverFn<unknown, Context>> => ({
117
+ queryTransaction: (parent, args, context, info) =>
118
+ context.timer(`GraphQL.query.${info.fieldName}`, () => context.executionContainer.readResolver.resolveTransaction(astFactory.create(info))),
119
+ mutationTransaction: (parent, args, context, info) =>
120
+ context.timer(`GraphQL.mutation.${info.fieldName}`, () => {
121
+ const queryAst = astFactory.create<{ options?: TransactionOptions }>(info, transactionQueryAstFilter)
122
+ return context.executionContainer.mutationResolver.resolveTransaction(queryAst, {
123
+ deferForeignKeyConstraints: queryAst.args.options?.deferForeignKeyConstraints ?? false,
124
+ deferUniqueConstraints: queryAst.args.options?.deferUniqueConstraints ?? false,
125
+ })
126
+ }),
127
+ mutationQuery: (parent, args, context, info) => context.executionContainer.readResolver.resolveQuery(astFactory.create(info)),
128
+ refreshView: (parent, args, context, info) => {
129
+ const ast = astFactory.create<{ name: string; options?: { concurrently?: boolean } }>(info, argumentsOnly)
130
+ return context.executionContainer.refreshViewResolver.resolve(ast.args.name, ast.args.options)
131
+ },
132
+ info: () => ({ description: 'TODO' }),
133
+ })
134
+
135
+ /**
136
+ * Builds the content schema as plain JSON for `@contember/graphql-json`, without graphql-js type instances.
137
+ * The printed schema must stay stable for clients; `graphQlSchemaBuilder.test.ts` compares it with recorded SDL.
138
+ */
139
+ export class JsonContentSchemaBuilder {
140
+ private readonly registry: JsonTypeRegistry
141
+ private readonly columnTypes: JsonColumnTypes
142
+ private readonly filterTypes: JsonFilterTypes
143
+ private readonly entityTypes: JsonEntityTypes
144
+ private readonly inputTypes: JsonInputTypes
145
+ private readonly schemaResolvers: ReturnType<typeof createSchemaResolvers>
146
+
147
+ /** `shared` is the state of the model; pass the same instance to every role's builder. */
148
+ constructor(
149
+ private readonly schema: Model.Schema,
150
+ private readonly authorizator: Authorizator,
151
+ private readonly rootAuthorizator: Authorizator,
152
+ private readonly shared: JsonContentSchemaShared = new JsonContentSchemaShared(),
153
+ ) {
154
+ this.registry = new JsonTypeRegistry(shared.resolvers, shared.extensions, shared.scalars)
155
+ this.schemaResolvers = createSchemaResolvers(shared.queryAstFactory)
156
+ this.columnTypes = new JsonColumnTypes(schema, this.registry)
157
+ this.filterTypes = new JsonFilterTypes(schema, authorizator, this.registry, this.columnTypes)
158
+ this.entityTypes = new JsonEntityTypes(schema, authorizator, rootAuthorizator, this.registry, this.columnTypes, this.filterTypes)
159
+ this.inputTypes = new JsonInputTypes(schema, authorizator, this.registry, this.columnTypes, this.filterTypes)
160
+ }
161
+
162
+ public build(extensions: readonly JsonSchemaExtension[] = []): JsonContentSchema {
163
+ const steps = this.buildSteps(extensions)
164
+ for (;;) {
165
+ const step = steps.next()
166
+ if (step.done) {
167
+ return step.value
168
+ }
169
+ }
170
+ }
171
+
172
+ /**
173
+ * `build` in steps of bounded size, so that a caller can pause in between and keep serving other requests: the
174
+ * schema of a large model with permissive roles takes seconds. Each builder runs it at most once.
175
+ */
176
+ public *buildSteps(extensions: readonly JsonSchemaExtension[] = []): Generator<void, JsonContentSchema> {
177
+ const registry = this.registry
178
+ // graphql-js always includes these two, introspection depends on them
179
+ registry.scalar('String', undefined)
180
+ registry.scalar('Boolean', undefined)
181
+
182
+ const queries: Record<string, JsonOutputField> = {}
183
+ const mutations: Record<string, JsonOutputField> = {}
184
+ // Extensions differ per schema (introspection depends on permissions, contributors on the identity), so their
185
+ // resolvers and scalars stay out of the shared maps.
186
+ const extensionResolvers: ResolverMap<Context> = {}
187
+ const extensionScalars: ScalarMap = {}
188
+ const addExtensionFields = (target: Record<string, JsonOutputField>, fields: Record<string, JsonOutputField>, typeNames: string[]) => {
189
+ for (const [name, { resolve, ...field }] of Object.entries(fields)) {
190
+ target[name] = field
191
+ if (resolve) {
192
+ for (const typeName of typeNames) {
193
+ ;(extensionResolvers[typeName] ??= {})[name] = resolve
194
+ }
195
+ }
196
+ }
197
+ }
198
+ for (const extension of extensions) {
199
+ Object.assign(registry.types, extension.types)
200
+ addExtensionFields(queries, extension.queries ?? {}, ['Query', 'QueryTransaction'])
201
+ addExtensionFields(mutations, extension.mutations ?? {}, ['Mutation', 'MutationTransaction'])
202
+ Object.assign(extensionScalars, extension.scalars)
203
+ for (const [typeName, typeResolvers] of Object.entries(extension.resolvers ?? {})) {
204
+ extensionResolvers[typeName] = { ...extensionResolvers[typeName], ...typeResolvers }
205
+ }
206
+ }
207
+
208
+ for (const entity of Object.values(this.schema.entities)) {
209
+ Object.assign(queries, this.getQueries(entity))
210
+ Object.assign(queries, this.getValidationQueries(entity))
211
+ Object.assign(mutations, this.getMutations(entity))
212
+ yield
213
+ }
214
+
215
+ const boolean = namedRef(registry.scalar('Boolean', undefined))
216
+ const string = namedRef(registry.scalar('String', undefined))
217
+
218
+ if (Object.keys(queries).length > 0) {
219
+ // copied now: the fields are created after `transaction` and `_info` are added to `queries`
220
+ const transactionQueries = { ...queries }
221
+ const queryTransaction = registry.object('QueryTransaction', () => transactionQueries)
222
+ queries.transaction = { type: namedRef(queryTransaction), resolve: this.schemaResolvers.queryTransaction }
223
+ }
224
+ const hasMutations = Object.keys(mutations).length > 0
225
+ if (hasMutations) {
226
+ const transactionMutations = { ...mutations }
227
+ const options = registry.inputObject('MutationTransactionOptions', () => ({
228
+ deferForeignKeyConstraints: [boolean],
229
+ deferUniqueConstraints: [boolean],
230
+ }))
231
+ const mutationTransaction = registry.object('MutationTransaction', () => ({
232
+ ok: { type: nonNullRef('Boolean') },
233
+ errorMessage: { type: string },
234
+ errors: { type: this.getErrorListType() },
235
+ validation: { type: nonNullRef(this.getValidationResultType()) },
236
+ ...transactionMutations,
237
+ query: { type: namedRef('Query') },
238
+ }))
239
+ mutations.transaction = {
240
+ type: nonNullRef(mutationTransaction),
241
+ args: { options: [namedRef(options)] },
242
+ resolve: this.schemaResolvers.mutationTransaction,
243
+ }
244
+ mutations.query = { type: nonNullRef('Query'), resolve: this.schemaResolvers.mutationQuery }
245
+ }
246
+
247
+ const refreshViewMutation = this.getRefreshViewMutation()
248
+ if (refreshViewMutation) {
249
+ mutations.refreshMaterializedView = refreshViewMutation
250
+ }
251
+
252
+ const info = registry.object('Info', () => ({ description: { type: string } }))
253
+ queries._info = { type: namedRef(info), resolve: this.schemaResolvers.info }
254
+
255
+ registry.object('Query', () => queries)
256
+ if (hasMutations || refreshViewMutation) {
257
+ registry.object('Mutation', () => mutations)
258
+ }
259
+
260
+ yield* registry.fillPending()
261
+
262
+ const includedTypes = extensions.flatMap(it => it.includedTypes ?? [])
263
+ // after the root types, graphql-js collects the argument types of the specified directives and introspection
264
+ const roots = ['Query', 'Mutation', 'Boolean', 'String', '__Schema']
265
+ // with the introspection types in place, graphql-json uses the schema as is instead of a merged copy
266
+ const types = yield* registry.collectReachableTypes(includedTypes, roots, introspectionTypes)
267
+ const schema = yield* this.shared.interner.internSteps({
268
+ q: 'Query',
269
+ m: registry.has('Mutation') ? 'Mutation' : null,
270
+ s: null,
271
+ t: types,
272
+ })
273
+ // not merged into a copy of the shared map: on a large model that copy costs ~0.2 MB per role
274
+ const resolvers = Object.keys(extensionResolvers).length > 0 ? [extensionResolvers, this.shared.resolvers] : [this.shared.resolvers]
275
+ return { schema, resolvers, scalars: { ...this.shared.scalars, ...extensionScalars } }
276
+ }
277
+
278
+ private getQueries(entity: Model.Entity): Record<string, JsonOutputField> {
279
+ // Root entry points are gated on the root grants alone, see QueryProvider.
280
+ if (this.rootAuthorizator.getEntityPermission(Acl.Operation.read, entity.name) === 'no') {
281
+ return {}
282
+ }
283
+ const entityName = entity.name
284
+ const entityType = this.entityTypes.getEntity(entityName)
285
+ const uniqueWhere = this.filterTypes.getEntityUniqueWhereType(entityName)
286
+ if (!uniqueWhere) {
287
+ throw new ImplementationException()
288
+ }
289
+ const where = namedRef(this.filterTypes.getEntityWhereType(entityName))
290
+ const int = namedRef(this.columnTypes.getScalar(Model.ColumnType.Int))
291
+ const resolvers = createQueryResolvers(entity, this.shared.queryAstFactory)
292
+ return {
293
+ ['get' + entityName]: {
294
+ type: namedRef(entityType),
295
+ args: { by: [nonNullRef(uniqueWhere)], filter: [where] },
296
+ deprecationReason: entity.deprecationReason,
297
+ extensions: { [ExtensionKey]: new OperationMeta(Operation.get, entity) },
298
+ resolve: resolvers.get,
299
+ },
300
+ ['list' + entityName]: {
301
+ type: nonNullListOfNonNullRef(entityType),
302
+ args: {
303
+ filter: [where],
304
+ orderBy: [listOfNonNullRef(this.filterTypes.getEntityOrderByType(entityName))],
305
+ offset: [int],
306
+ limit: [int],
307
+ },
308
+ deprecationReason: entity.deprecationReason,
309
+ extensions: { [ExtensionKey]: new OperationMeta(Operation.list, entity) },
310
+ resolve: resolvers.list,
311
+ },
312
+ ['paginate' + entityName]: {
313
+ ...this.entityTypes.createPaginatedField(entityName),
314
+ deprecationReason: entity.deprecationReason,
315
+ extensions: { [ExtensionKey]: new OperationMeta(Operation.paginate, entity) },
316
+ resolve: resolvers.paginate,
317
+ },
318
+ }
319
+ }
320
+
321
+ private getValidationQueries(entity: Model.Entity): Record<string, JsonOutputField> {
322
+ const fields: Record<string, JsonOutputField> = {}
323
+ const createInput = this.inputTypes.getInput(EntityInputType.create, entity.name)
324
+ const validationResult = nonNullRef(this.getValidationResultType())
325
+ const resolvers = createValidationResolvers(entity, this.shared.queryAstFactory)
326
+ if (createInput !== undefined) {
327
+ fields[`validateCreate${entity.name}`] = {
328
+ type: validationResult,
329
+ args: { data: [nonNullRef(createInput)] },
330
+ deprecationReason: entity.deprecationReason,
331
+ resolve: resolvers.create,
332
+ }
333
+ }
334
+ const updateInput = this.inputTypes.getInput(EntityInputType.update, entity.name)
335
+ const uniqueWhere = this.filterTypes.getEntityUniqueWhereType(entity.name)
336
+ if (updateInput !== undefined && uniqueWhere !== undefined) {
337
+ fields[`validateUpdate${entity.name}`] = {
338
+ type: validationResult,
339
+ args: { by: [nonNullRef(uniqueWhere)], data: [nonNullRef(updateInput)] },
340
+ deprecationReason: entity.deprecationReason,
341
+ resolve: resolvers.update,
342
+ }
343
+ }
344
+ return fields
345
+ }
346
+
347
+ private getMutations(entity: Model.Entity): Record<string, JsonOutputField> {
348
+ const entityName = entity.name
349
+ const mutations: Record<string, JsonOutputField> = {}
350
+ const isLookupReadable = this.authorizator.getEntityPermission(Acl.Operation.read, entityName) !== 'no'
351
+ const rootAllows = (operation: Acl.Operation) => this.rootAuthorizator.getEntityPermission(operation, entityName) !== 'no'
352
+ const resolvers = createMutationResolvers(entity, this.shared.queryAstFactory)
353
+
354
+ if (rootAllows(Acl.Operation.create)) {
355
+ const dataType = this.inputTypes.getInput(EntityInputType.create, entityName)
356
+ if (dataType !== undefined) {
357
+ mutations[`create${entityName}`] = {
358
+ type: nonNullRef(this.createResultType(entityName, 'create')),
359
+ args: { data: [nonNullRef(dataType)] },
360
+ deprecationReason: entity.deprecationReason,
361
+ extensions: { [ExtensionKey]: new OperationMeta(Operation.create, entity) },
362
+ resolve: resolvers.create,
363
+ }
364
+ }
365
+ }
366
+
367
+ const uniqueWhere = this.filterTypes.getEntityUniqueWhereType(entityName)
368
+ if (!entity.view && isLookupReadable && rootAllows(Acl.Operation.delete) && uniqueWhere) {
369
+ mutations[`delete${entityName}`] = {
370
+ type: nonNullRef(this.createResultType(entityName, 'delete')),
371
+ args: {
372
+ by: [nonNullRef(uniqueWhere)],
373
+ filter: [namedRef(this.filterTypes.getEntityWhereType(entityName))],
374
+ },
375
+ deprecationReason: entity.deprecationReason,
376
+ extensions: { [ExtensionKey]: new OperationMeta(Operation.delete, entity) },
377
+ resolve: resolvers.delete,
378
+ }
379
+ }
380
+
381
+ if (isLookupReadable && rootAllows(Acl.Operation.update)) {
382
+ const dataType = this.inputTypes.getInput(EntityInputType.update, entityName)
383
+ if (dataType !== undefined) {
384
+ const resultType = this.createResultType(entityName, 'update')
385
+ if (uniqueWhere) {
386
+ mutations[`update${entityName}`] = {
387
+ type: nonNullRef(resultType),
388
+ args: {
389
+ by: [nonNullRef(uniqueWhere)],
390
+ filter: [namedRef(this.filterTypes.getEntityWhereType(entityName))],
391
+ data: [nonNullRef(dataType)],
392
+ },
393
+ deprecationReason: entity.deprecationReason,
394
+ extensions: { [ExtensionKey]: new OperationMeta(Operation.update, entity) },
395
+ resolve: resolvers.update,
396
+ }
397
+ }
398
+ }
399
+ }
400
+
401
+ if (isLookupReadable && rootAllows(Acl.Operation.update) && rootAllows(Acl.Operation.create)) {
402
+ const createInput = this.inputTypes.getInput(EntityInputType.create, entityName)
403
+ const updateInput = this.inputTypes.getInput(EntityInputType.update, entityName)
404
+ if (createInput !== undefined && updateInput !== undefined) {
405
+ const resultType = this.createResultType(entityName, 'upsert')
406
+ if (uniqueWhere) {
407
+ mutations[`upsert${entityName}`] = {
408
+ type: nonNullRef(resultType),
409
+ args: {
410
+ by: [nonNullRef(uniqueWhere)],
411
+ filter: [namedRef(this.filterTypes.getEntityWhereType(entityName))],
412
+ update: [nonNullRef(updateInput)],
413
+ create: [nonNullRef(createInput)],
414
+ },
415
+ deprecationReason: entity.deprecationReason,
416
+ extensions: { [ExtensionKey]: new OperationMeta(Operation.upsert, entity) },
417
+ resolve: resolvers.upsert,
418
+ }
419
+ }
420
+ }
421
+ }
422
+ return mutations
423
+ }
424
+
425
+ private createResultType(entityName: string, operation: 'create' | 'update' | 'delete' | 'upsert'): string {
426
+ const mutationResult = this.getMutationResultType()
427
+ return this.registry.object(GqlTypeName`${entityName}${operation}Result`, () => {
428
+ const fields: Record<string, JsonOutputField> = {
429
+ ok: { type: nonNullRef('Boolean') },
430
+ errorMessage: { type: namedRef('String') },
431
+ errors: { type: this.getErrorListType() },
432
+ }
433
+ if (this.authorizator.getEntityPermission(Acl.Operation.read, entityName) !== 'no') {
434
+ fields.node = { type: namedRef(this.entityTypes.getEntity(entityName)), resolve: aliasAwareResolver }
435
+ }
436
+ if (operation !== 'delete') {
437
+ fields.validation = { type: nonNullRef(this.getValidationResultType()) }
438
+ }
439
+ return fields
440
+ }, [mutationResult])
441
+ }
442
+
443
+ private getPathFragmentType(): string {
444
+ const string = namedRef(this.registry.scalar('String', undefined))
445
+ const int = this.columnTypes.getScalar(Model.ColumnType.Int)
446
+ return this.registry.union('_PathFragment', [
447
+ this.registry.object('_FieldPathFragment', () => ({ field: { type: nonNullRef('String') } })),
448
+ this.registry.object('_IndexPathFragment', () => ({ index: { type: nonNullRef(int) }, alias: { type: string } })),
449
+ ])
450
+ }
451
+
452
+ private getValidationResultType(): string {
453
+ const pathFragment = this.getPathFragmentType()
454
+ const validationMessage = this.registry.object('_ValidationMessage', () => ({ text: { type: nonNullRef('String') } }))
455
+ const validationError = this.registry.object('_ValidationError', () => ({
456
+ path: { type: nonNullListOfNonNullRef(pathFragment) },
457
+ message: { type: nonNullRef(validationMessage) },
458
+ }))
459
+ return this.registry.object('_ValidationResult', () => ({
460
+ valid: { type: nonNullRef('Boolean') },
461
+ errors: { type: nonNullListOfNonNullRef(validationError) },
462
+ }))
463
+ }
464
+
465
+ private getErrorListType() {
466
+ const pathFragment = this.getPathFragmentType()
467
+ const errorType = this.registry.enum('_MutationErrorType', Object.values(Result.ExecutionErrorType))
468
+ return nonNullListOfNonNullRef(this.registry.object('_MutationError', () => ({
469
+ path: { type: nonNullListOfNonNullRef(pathFragment), deprecationReason: 'Use `paths`.' },
470
+ paths: { type: nonNullListOfNonNullListOfNonNullRef(pathFragment) },
471
+ type: { type: nonNullRef(errorType) },
472
+ message: { type: namedRef('String') },
473
+ })))
474
+ }
475
+
476
+ private getMutationResultType(): string {
477
+ return this.registry.interface('MutationResult', () => ({
478
+ ok: { type: nonNullRef('Boolean') },
479
+ errorMessage: { type: namedRef('String') },
480
+ errors: { type: this.getErrorListType() },
481
+ }))
482
+ }
483
+
484
+ private getRefreshViewMutation(): JsonOutputField | undefined {
485
+ const materializedViews = Object.values(this.schema.entities)
486
+ .filter(it => it.view?.materialized)
487
+ .filter(it => this.authorizator.isRefreshMaterializedViewAllowed(it.name))
488
+ if (materializedViews.length === 0) {
489
+ return undefined
490
+ }
491
+ const boolean = namedRef(this.registry.scalar('Boolean', undefined))
492
+ return {
493
+ type: namedRef(this.registry.object('RefreshMaterializedViewResponse', () => ({ ok: { type: boolean } }))),
494
+ args: {
495
+ name: [namedRef(this.registry.enum('_MaterializedView', materializedViews.map(it => it.name)))],
496
+ options: [namedRef(this.registry.inputObject('RefreshMaterializedViewOptions', () => ({ concurrently: [boolean] })))],
497
+ },
498
+ resolve: this.schemaResolvers.refreshView,
499
+ }
500
+ }
501
+ }
@@ -0,0 +1,19 @@
1
+ import { builtInScalars, ResolverMap, ScalarImplementation, SchemaInterner } from '@contember/graphql-json'
2
+ import { Context } from '../types.js'
3
+ import { JsonQueryAstFactory } from './JsonQueryAstFactory.js'
4
+ import { FieldExtensions } from './JsonTypeRegistry.js'
5
+
6
+ /**
7
+ * The parts of the JSON content schemas of one model that do not depend on permissions. Each role combination
8
+ * builds its own schema, but resolvers, field extensions and scalars depend only on the model and are keyed by
9
+ * type and field name, so they accumulate here; the schema data is interned, so a role pays only for what its
10
+ * permissions change.
11
+ */
12
+ export class JsonContentSchemaShared {
13
+ public readonly resolvers: ResolverMap<Context> = {}
14
+ public readonly extensions: Record<string, Record<string, FieldExtensions>> = {}
15
+ /** Includes the built-in scalars, so a lookup sees what later builds register. */
16
+ public readonly scalars: Record<string, ScalarImplementation> = { ...builtInScalars }
17
+ public readonly interner = new SchemaInterner()
18
+ public readonly queryAstFactory = new JsonQueryAstFactory(this.scalars, this.extensions)
19
+ }