@contember/engine-content-api 2.1.0-rc.6 → 2.1.0-rc.8

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 (121) hide show
  1. package/CLAUDE.md +2 -0
  2. package/dist/development/src/mapper/ErrorUtils.cjs +7 -1
  3. package/dist/development/src/mapper/ErrorUtils.cjs.map +1 -1
  4. package/dist/development/src/mapper/ErrorUtils.js +7 -1
  5. package/dist/development/src/mapper/ErrorUtils.js.map +1 -1
  6. package/dist/development/src/mapper/Mapper.cjs +2 -1
  7. package/dist/development/src/mapper/Mapper.cjs.map +1 -1
  8. package/dist/development/src/mapper/Mapper.js +2 -1
  9. package/dist/development/src/mapper/Mapper.js.map +1 -1
  10. package/dist/development/src/mapper/select/Path.cjs +23 -3
  11. package/dist/development/src/mapper/select/Path.cjs.map +1 -1
  12. package/dist/development/src/mapper/select/Path.js +23 -3
  13. package/dist/development/src/mapper/select/Path.js.map +1 -1
  14. package/dist/development/src/mapper/select/SelectBuilder.cjs +13 -10
  15. package/dist/development/src/mapper/select/SelectBuilder.cjs.map +1 -1
  16. package/dist/development/src/mapper/select/SelectBuilder.js +13 -10
  17. package/dist/development/src/mapper/select/SelectBuilder.js.map +1 -1
  18. package/dist/development/src/mapper/select/handlers/FieldsVisitor.cjs +1 -1
  19. package/dist/development/src/mapper/select/handlers/FieldsVisitor.cjs.map +1 -1
  20. package/dist/development/src/mapper/select/handlers/FieldsVisitor.js +1 -1
  21. package/dist/development/src/mapper/select/handlers/FieldsVisitor.js.map +1 -1
  22. package/dist/development/src/mapper/select/handlers/MetaHandler.cjs +4 -3
  23. package/dist/development/src/mapper/select/handlers/MetaHandler.cjs.map +1 -1
  24. package/dist/development/src/mapper/select/handlers/MetaHandler.js +4 -3
  25. package/dist/development/src/mapper/select/handlers/MetaHandler.js.map +1 -1
  26. package/dist/development/src/resolvers/MutationResolver.cjs +1 -0
  27. package/dist/development/src/resolvers/MutationResolver.cjs.map +1 -1
  28. package/dist/development/src/resolvers/MutationResolver.js +1 -0
  29. package/dist/development/src/resolvers/MutationResolver.js.map +1 -1
  30. package/dist/production/src/mapper/ErrorUtils.cjs +7 -1
  31. package/dist/production/src/mapper/ErrorUtils.cjs.map +1 -1
  32. package/dist/production/src/mapper/ErrorUtils.js +7 -1
  33. package/dist/production/src/mapper/ErrorUtils.js.map +1 -1
  34. package/dist/production/src/mapper/Mapper.cjs +2 -1
  35. package/dist/production/src/mapper/Mapper.cjs.map +1 -1
  36. package/dist/production/src/mapper/Mapper.js +2 -1
  37. package/dist/production/src/mapper/Mapper.js.map +1 -1
  38. package/dist/production/src/mapper/select/Path.cjs +23 -3
  39. package/dist/production/src/mapper/select/Path.cjs.map +1 -1
  40. package/dist/production/src/mapper/select/Path.js +23 -3
  41. package/dist/production/src/mapper/select/Path.js.map +1 -1
  42. package/dist/production/src/mapper/select/SelectBuilder.cjs +13 -10
  43. package/dist/production/src/mapper/select/SelectBuilder.cjs.map +1 -1
  44. package/dist/production/src/mapper/select/SelectBuilder.js +13 -10
  45. package/dist/production/src/mapper/select/SelectBuilder.js.map +1 -1
  46. package/dist/production/src/mapper/select/handlers/FieldsVisitor.cjs +1 -1
  47. package/dist/production/src/mapper/select/handlers/FieldsVisitor.cjs.map +1 -1
  48. package/dist/production/src/mapper/select/handlers/FieldsVisitor.js +1 -1
  49. package/dist/production/src/mapper/select/handlers/FieldsVisitor.js.map +1 -1
  50. package/dist/production/src/mapper/select/handlers/MetaHandler.cjs +4 -3
  51. package/dist/production/src/mapper/select/handlers/MetaHandler.cjs.map +1 -1
  52. package/dist/production/src/mapper/select/handlers/MetaHandler.js +4 -3
  53. package/dist/production/src/mapper/select/handlers/MetaHandler.js.map +1 -1
  54. package/dist/production/src/resolvers/MutationResolver.cjs +1 -0
  55. package/dist/production/src/resolvers/MutationResolver.cjs.map +1 -1
  56. package/dist/production/src/resolvers/MutationResolver.js +1 -0
  57. package/dist/production/src/resolvers/MutationResolver.js.map +1 -1
  58. package/dist/tests/cases/integration/graphQlRequests/query/acl/internalColumnAliases.test.d.ts +2 -0
  59. package/dist/tests/cases/integration/graphQlRequests/query/acl/internalColumnAliases.test.d.ts.map +1 -0
  60. package/dist/tests/cases/integration/graphQlRequests/query/acl/mergedRolePredicate.test.d.ts +2 -0
  61. package/dist/tests/cases/integration/graphQlRequests/query/acl/mergedRolePredicate.test.d.ts.map +1 -0
  62. package/dist/tests/cases/integration/graphQlRequests/query/acl/nestedThroughPredicate.test.d.ts +2 -0
  63. package/dist/tests/cases/integration/graphQlRequests/query/acl/nestedThroughPredicate.test.d.ts.map +1 -0
  64. package/dist/tests/cases/unit/internalColumnAliases.test.d.ts +2 -0
  65. package/dist/tests/cases/unit/internalColumnAliases.test.d.ts.map +1 -0
  66. package/dist/tests/cases/unit/mutationSqlError.test.d.ts +2 -0
  67. package/dist/tests/cases/unit/mutationSqlError.test.d.ts.map +1 -0
  68. package/dist/tests/cases/unit/pathAlias.test.d.ts +2 -0
  69. package/dist/tests/cases/unit/pathAlias.test.d.ts.map +1 -0
  70. package/dist/tests/src/test.d.ts +1 -0
  71. package/dist/tests/src/test.d.ts.map +1 -1
  72. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  73. package/dist/types/mapper/ErrorUtils.d.ts.map +1 -1
  74. package/dist/types/mapper/select/Path.d.ts +1 -0
  75. package/dist/types/mapper/select/Path.d.ts.map +1 -1
  76. package/dist/types/mapper/select/SelectBuilder.d.ts.map +1 -1
  77. package/dist/types/mapper/select/SelectExecutionHandler.d.ts +11 -1
  78. package/dist/types/mapper/select/SelectExecutionHandler.d.ts.map +1 -1
  79. package/dist/types/mapper/select/handlers/MetaHandler.d.ts.map +1 -1
  80. package/dist/types/tsconfig.tsbuildinfo +1 -1
  81. package/package.json +9 -9
  82. package/src/mapper/ErrorUtils.ts +11 -1
  83. package/src/mapper/Mapper.ts +1 -1
  84. package/src/mapper/select/Path.ts +25 -5
  85. package/src/mapper/select/SelectBuilder.ts +22 -11
  86. package/src/mapper/select/SelectExecutionHandler.ts +9 -1
  87. package/src/mapper/select/handlers/FieldsVisitor.ts +1 -1
  88. package/src/mapper/select/handlers/MetaHandler.ts +8 -3
  89. package/tests/cases/bugs/bug102.test.ts +4 -4
  90. package/tests/cases/integration/graphQlRequests/delete/deleteById.test.ts +4 -3
  91. package/tests/cases/integration/graphQlRequests/query/acl/differentRowAndFieldPredicate.test.ts +4 -4
  92. package/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.ts +12 -10
  93. package/tests/cases/integration/graphQlRequests/query/acl/internalColumnAliases.test.ts +326 -0
  94. package/tests/cases/integration/graphQlRequests/query/acl/mergedRolePredicate.test.ts +124 -0
  95. package/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.ts +7 -6
  96. package/tests/cases/integration/graphQlRequests/query/acl/nestedThroughPredicate.test.ts +345 -0
  97. package/tests/cases/integration/graphQlRequests/query/acl/predicateElimination.test.ts +25 -23
  98. package/tests/cases/integration/graphQlRequests/query/acl/relationAcl.test.ts +12 -9
  99. package/tests/cases/integration/graphQlRequests/query/acl/rowPredicateSubset.test.ts +6 -6
  100. package/tests/cases/integration/graphQlRequests/query/filter/backReferencedFilter.test.ts +3 -1
  101. package/tests/cases/integration/graphQlRequests/query/graphqlFeatures/alias.test.ts +2 -2
  102. package/tests/cases/integration/graphQlRequests/query/graphqlFeatures/fragments.test.ts +8 -8
  103. package/tests/cases/integration/graphQlRequests/query/misc/reducedHasMany.test.ts +10 -10
  104. package/tests/cases/integration/graphQlRequests/query/pagination/hasManyLimit.test.ts +8 -8
  105. package/tests/cases/integration/graphQlRequests/query/pagination/paginate.test.ts +5 -4
  106. package/tests/cases/integration/graphQlRequests/query/pagination/paginateAliased.test.ts +5 -4
  107. package/tests/cases/integration/graphQlRequests/query/relations/advanced.test.ts +17 -8
  108. package/tests/cases/integration/graphQlRequests/query/relations/manyHasManyInverse.test.ts +6 -6
  109. package/tests/cases/integration/graphQlRequests/query/relations/manyHasManyOwning.test.ts +6 -6
  110. package/tests/cases/integration/graphQlRequests/query/relations/manyHasOne.test.ts +12 -9
  111. package/tests/cases/integration/graphQlRequests/query/relations/oneHasMany.test.ts +12 -12
  112. package/tests/cases/integration/graphQlRequests/query/relations/oneHasOneInverse.test.ts +6 -4
  113. package/tests/cases/integration/graphQlRequests/query/relations/oneHasOneOwner.test.ts +6 -4
  114. package/tests/cases/integration/graphQlRequests/query/sorting/defaultOrdering.test.ts +4 -4
  115. package/tests/cases/integration/graphQlRequests/query/sorting/randomSort.test.ts +5 -5
  116. package/tests/cases/integration/graphQlRequests/query/sorting/sortedHasMany.test.ts +2 -2
  117. package/tests/cases/integration/graphQlRequests/query/view/view.test.ts +6 -6
  118. package/tests/cases/unit/internalColumnAliases.test.ts +41 -0
  119. package/tests/cases/unit/mutationSqlError.test.ts +30 -0
  120. package/tests/cases/unit/pathAlias.test.ts +26 -0
  121. package/tests/src/test.ts +5 -1
@@ -0,0 +1,326 @@
1
+ import { c, createSchema, SchemaBuilder, SchemaDefinition as def } from '@contember/schema-definition'
2
+ import { Acl, Model } from '@contember/schema'
3
+ import { test } from 'bun:test'
4
+ import { execute } from '../../../../../src/test'
5
+ import { GQL, SQL } from '../../../../../src/tags'
6
+ import { testUuid } from '../../../../../src/testUuid'
7
+ import { viewComputedId } from '../../../../../../src/utils/viewComputedId'
8
+
9
+ // A client chooses GraphQL aliases freely, and they become SQL column aliases. Engine-owned columns (ACL predicate
10
+ // results, relation keys) must stay in a namespace no alias can reach, otherwise the client's column is read instead.
11
+
12
+ const schema = new SchemaBuilder()
13
+ .entity('Author', entity =>
14
+ entity
15
+ .column('name', column => column.type(Model.ColumnType.String))
16
+ .column('verified', column => column.type(Model.ColumnType.Bool)))
17
+ .entity('Post', entity =>
18
+ entity
19
+ .column('externalId', column => column.type(Model.ColumnType.Uuid))
20
+ .manyHasOne('author', relation => relation.target('Author')))
21
+ .buildSchema()
22
+
23
+ const longPredicateName = 'nameVisible' + 'Long'.repeat(13)
24
+
25
+ const permissions: Acl.Permissions = {
26
+ Author: {
27
+ predicates: {
28
+ nameVisible: { verified: { eq: true } },
29
+ [longPredicateName]: { verified: { eq: true } },
30
+ },
31
+ operations: {
32
+ read: { id: true, verified: true, name: 'nameVisible' },
33
+ update: { name: 'nameVisible' },
34
+ },
35
+ },
36
+ Post: {
37
+ predicates: {},
38
+ operations: {
39
+ read: { id: true, externalId: true, author: true },
40
+ },
41
+ },
42
+ }
43
+
44
+ test('a root alias equal to a predicate column does not unmask the field', async () => {
45
+ await execute({
46
+ schema,
47
+ permissions,
48
+ query: GQL`
49
+ query {
50
+ listAuthor {
51
+ id
52
+ name
53
+ __predicate_nameVisible: verified
54
+ }
55
+ }`,
56
+ executes: [
57
+ {
58
+ sql: SQL`
59
+ select "root_"."id" as "root_id",
60
+ "root_"."verified" = ? as "root_$predicate_nameVisible",
61
+ "root_"."name" as "root_name",
62
+ "root_"."verified" as "root___predicate_nameVisible"
63
+ from "public"."author" as "root_"`,
64
+ parameters: [true],
65
+ response: {
66
+ rows: [
67
+ {
68
+ root_id: testUuid(1),
69
+ 'root_$predicate_nameVisible': false,
70
+ root_name: 'masked',
71
+ root___predicate_nameVisible: true,
72
+ },
73
+ ],
74
+ },
75
+ },
76
+ ],
77
+ return: {
78
+ data: {
79
+ listAuthor: [{ id: testUuid(1), name: null, __predicate_nameVisible: true }],
80
+ },
81
+ },
82
+ })
83
+ })
84
+
85
+ test('a nested alias equal to a predicate column does not unmask the field', async () => {
86
+ await execute({
87
+ schema,
88
+ permissions,
89
+ query: GQL`
90
+ query {
91
+ listPost {
92
+ id
93
+ author {
94
+ id
95
+ name
96
+ __predicate_nameVisible: verified
97
+ }
98
+ }
99
+ }`,
100
+ executes: [
101
+ {
102
+ sql: SQL`
103
+ select "root_"."id" as "root_id",
104
+ "root_"."author_id" as "root_$key_author"
105
+ from "public"."post" as "root_"`,
106
+ parameters: [],
107
+ response: {
108
+ rows: [{ root_id: testUuid(1), 'root_$key_author': testUuid(2) }],
109
+ },
110
+ },
111
+ {
112
+ sql: SQL`
113
+ select "root_"."id" as "root_$index_id",
114
+ "root_"."id" as "root_id",
115
+ "root_"."verified" = ? as "root_$predicate_nameVisible",
116
+ "root_"."name" as "root_name",
117
+ "root_"."verified" as "root___predicate_nameVisible"
118
+ from "public"."author" as "root_"
119
+ where "root_"."id" in (?)`,
120
+ parameters: [true, testUuid(2)],
121
+ response: {
122
+ rows: [
123
+ {
124
+ 'root_$index_id': testUuid(2),
125
+ root_id: testUuid(2),
126
+ 'root_$predicate_nameVisible': false,
127
+ root_name: 'masked',
128
+ root___predicate_nameVisible: true,
129
+ },
130
+ ],
131
+ },
132
+ },
133
+ ],
134
+ return: {
135
+ data: {
136
+ listPost: [{ id: testUuid(1), author: { id: testUuid(2), name: null, __predicate_nameVisible: true } }],
137
+ },
138
+ },
139
+ })
140
+ })
141
+
142
+ test('an alias equal to a predicate column does not change _meta.updatable', async () => {
143
+ await execute({
144
+ schema,
145
+ permissions,
146
+ query: GQL`
147
+ query {
148
+ listAuthor {
149
+ id
150
+ __predicate_nameVisible: verified
151
+ _meta {
152
+ name {
153
+ updatable
154
+ }
155
+ }
156
+ }
157
+ }`,
158
+ executes: [
159
+ {
160
+ sql: SQL`
161
+ select "root_"."id" as "root_id",
162
+ "root_"."verified" as "root___predicate_nameVisible",
163
+ "root_"."verified" = ? as "root_$predicate_nameVisible"
164
+ from "public"."author" as "root_"`,
165
+ parameters: [true],
166
+ response: {
167
+ rows: [
168
+ {
169
+ root_id: testUuid(1),
170
+ root___predicate_nameVisible: true,
171
+ 'root_$predicate_nameVisible': false,
172
+ },
173
+ ],
174
+ },
175
+ },
176
+ ],
177
+ return: {
178
+ data: {
179
+ listAuthor: [{ id: testUuid(1), __predicate_nameVisible: true, _meta: { name: { updatable: false } } }],
180
+ },
181
+ },
182
+ })
183
+ })
184
+
185
+ test('aliases over the identifier length limit stay apart from predicate columns', async () => {
186
+ const longPermissions: Acl.Permissions = {
187
+ ...permissions,
188
+ Author: {
189
+ ...permissions.Author,
190
+ operations: {
191
+ read: { id: true, verified: true, name: longPredicateName },
192
+ },
193
+ },
194
+ }
195
+ await execute({
196
+ schema,
197
+ permissions: longPermissions,
198
+ query: `
199
+ query {
200
+ listAuthor {
201
+ id
202
+ name
203
+ __predicate_${longPredicateName}: verified
204
+ }
205
+ }`,
206
+ executes: [
207
+ {
208
+ sql: SQL`
209
+ select "root_"."id" as "root_id",
210
+ "root_"."verified" = ? as "root_$predicate_nameVisibleLongLongLongLongLongLongLongLongLo_1",
211
+ "root_"."name" as "root_name",
212
+ "root_"."verified" as "root___predicate_nameVisibleLongLongLongLongLongLongLongLongL_2"
213
+ from "public"."author" as "root_"`,
214
+ parameters: [true],
215
+ response: {
216
+ rows: [
217
+ {
218
+ root_id: testUuid(1),
219
+ 'root_$predicate_nameVisibleLongLongLongLongLongLongLongLongLo_1': false,
220
+ root_name: 'masked',
221
+ root___predicate_nameVisibleLongLongLongLongLongLongLongLongL_2: true,
222
+ },
223
+ ],
224
+ },
225
+ },
226
+ ],
227
+ return: {
228
+ data: {
229
+ listAuthor: [{ id: testUuid(1), name: null, [`__predicate_${longPredicateName}`]: true }],
230
+ },
231
+ },
232
+ })
233
+ })
234
+
235
+ test('an alias equal to a relation field does not replace the relation key', async () => {
236
+ await execute({
237
+ schema,
238
+ permissions,
239
+ query: GQL`
240
+ query {
241
+ listPost {
242
+ id
243
+ writer: author {
244
+ id
245
+ }
246
+ author: externalId
247
+ }
248
+ }`,
249
+ executes: [
250
+ {
251
+ sql: SQL`
252
+ select "root_"."id" as "root_id",
253
+ "root_"."author_id" as "root_$key_author",
254
+ "root_"."external_id" as "root_author"
255
+ from "public"."post" as "root_"`,
256
+ parameters: [],
257
+ response: {
258
+ rows: [{ root_id: testUuid(1), 'root_$key_author': testUuid(2), root_author: testUuid(9) }],
259
+ },
260
+ },
261
+ {
262
+ sql: SQL`
263
+ select "root_"."id" as "root_$index_id",
264
+ "root_"."id" as "root_id"
265
+ from "public"."author" as "root_"
266
+ where "root_"."id" in (?)`,
267
+ parameters: [testUuid(2)],
268
+ response: {
269
+ rows: [{ 'root_$index_id': testUuid(2), root_id: testUuid(2) }],
270
+ },
271
+ },
272
+ ],
273
+ return: {
274
+ data: {
275
+ listPost: [{ id: testUuid(1), writer: { id: testUuid(2) }, author: testUuid(9) }],
276
+ },
277
+ },
278
+ })
279
+ })
280
+
281
+ namespace ViewSchema {
282
+ @c.View(`SELECT gen_random_uuid() AS id, 'a' AS first, 'b' AS second`, { idSource: ['first', 'second'] })
283
+ export class Pair {
284
+ first = def.stringColumn()
285
+ second = def.stringColumn()
286
+ }
287
+ }
288
+
289
+ test('an alias equal to a view id source column does not change the computed id', async () => {
290
+ await execute({
291
+ schema: createSchema(ViewSchema).model,
292
+ query: GQL`
293
+ query {
294
+ listPair {
295
+ id
296
+ id_first__id_src: second
297
+ }
298
+ }`,
299
+ executes: [
300
+ {
301
+ sql: SQL`
302
+ select "root_"."first" as "root_id_$idSrc_first",
303
+ "root_"."second" as "root_id_$idSrc_second",
304
+ "root_"."id" as "root_id",
305
+ "root_"."second" as "root_id_first__id_src"
306
+ from "public"."pair" as "root_"`,
307
+ parameters: [],
308
+ response: {
309
+ rows: [
310
+ {
311
+ 'root_id_$idSrc_first': 'a',
312
+ 'root_id_$idSrc_second': 'b',
313
+ root_id: testUuid(1),
314
+ root_id_first__id_src: 'b',
315
+ },
316
+ ],
317
+ },
318
+ },
319
+ ],
320
+ return: {
321
+ data: {
322
+ listPair: [{ id: viewComputedId(['a', 'b']), id_first__id_src: 'b' }],
323
+ },
324
+ },
325
+ })
326
+ })
@@ -0,0 +1,124 @@
1
+ import { SchemaBuilder } from '@contember/schema-definition'
2
+ import { Acl, Model, Schema } from '@contember/schema'
3
+ import { emptySchema } from '@contember/schema-utils'
4
+ import { expect, test } from 'bun:test'
5
+ import { PermissionFactory } from '../../../../../../src'
6
+ import { execute } from '../../../../../src/test'
7
+ import { GQL, SQL } from '../../../../../src/tags'
8
+ import { testUuid } from '../../../../../src/testUuid'
9
+
10
+ // Two roles granting a field with equally named predicates (as generated from equal conditions), plus a `through`
11
+ // grant from a third role, make the merger mint a name that exists only in the through-inclusive set:
12
+ // `__merge____merge__p__p__q`.
13
+
14
+ const model = new SchemaBuilder()
15
+ .entity('Project', entity => entity.oneHasMany('versions', c => c.target('Version').ownedBy('project')))
16
+ .entity('Version', entity =>
17
+ entity
18
+ .column('label', column => column.type(Model.ColumnType.String))
19
+ .column('isPublic', column => column.type(Model.ColumnType.Bool))
20
+ .column('isHidden', column => column.type(Model.ColumnType.Bool)))
21
+ .buildSchema()
22
+
23
+ // Each role gets its own definition object, as roles loaded from a stored schema do.
24
+ const createRoleWithLabel = (): Acl.RolePermissions => ({
25
+ variables: {},
26
+ stages: '*',
27
+ entities: {
28
+ Project: { predicates: {}, operations: { read: { id: true, versions: true } } },
29
+ Version: {
30
+ predicates: { isPublic: { isPublic: { eq: true } } },
31
+ operations: { read: { id: true, project: true, label: 'isPublic' } },
32
+ },
33
+ },
34
+ })
35
+
36
+ const schema: Schema = {
37
+ ...emptySchema,
38
+ model,
39
+ acl: {
40
+ roles: {
41
+ editor: createRoleWithLabel(),
42
+ viewer: createRoleWithLabel(),
43
+ listing: {
44
+ variables: {},
45
+ stages: '*',
46
+ entities: {
47
+ Version: {
48
+ predicates: { notHidden: { isHidden: { eq: false } } },
49
+ operations: { read: { id: true, label: 'notHidden' }, noRoot: ['read'] },
50
+ },
51
+ },
52
+ },
53
+ },
54
+ },
55
+ }
56
+
57
+ test('nested cell predicate minted by merging roles twice is resolved', async () => {
58
+ const { root, all } = new PermissionFactory().createContextual(schema, ['editor', 'viewer', 'listing'])
59
+ const mergedName = '__merge____merge__isPublic__isPublic__notHidden'
60
+ expect(all.Version.operations.read?.label).toBe(mergedName)
61
+ expect(root.Version.operations.read?.label).toBe('__merge__isPublic__isPublic')
62
+ expect(root.Version.predicates[mergedName]).toBeUndefined()
63
+
64
+ await execute({
65
+ schema: model,
66
+ permissions: root,
67
+ allPermissions: all,
68
+ query: GQL`
69
+ query {
70
+ listProject {
71
+ versions {
72
+ id
73
+ label
74
+ }
75
+ }
76
+ }`,
77
+ executes: [
78
+ {
79
+ sql: SQL`select "root_"."id" as "root_$key_id", "root_"."id" as "root_id" from "public"."project" as "root_"`,
80
+ parameters: [],
81
+ response: {
82
+ rows: [{ root_id: testUuid(1), 'root_$key_id': testUuid(1) }],
83
+ },
84
+ },
85
+ {
86
+ sql: SQL`
87
+ select "root_"."project_id" as "__grouping_key",
88
+ "root_"."id" as "root_id",
89
+ ("root_"."is_public" = ? or "root_"."is_hidden" = ?) as "root_$predicate___merge____merge__isPublic__isPublic__notHidd_1",
90
+ "root_"."label" as "root_label"
91
+ from "public"."version" as "root_" where "root_"."project_id" in (?)`,
92
+ parameters: [true, false, testUuid(1)],
93
+ response: {
94
+ rows: [
95
+ {
96
+ __grouping_key: testUuid(1),
97
+ root_id: testUuid(2),
98
+ 'root_$predicate___merge____merge__isPublic__isPublic__notHidd_1': true,
99
+ root_label: 'v1',
100
+ },
101
+ {
102
+ __grouping_key: testUuid(1),
103
+ root_id: testUuid(3),
104
+ 'root_$predicate___merge____merge__isPublic__isPublic__notHidd_1': false,
105
+ root_label: 'v2',
106
+ },
107
+ ],
108
+ },
109
+ },
110
+ ],
111
+ return: {
112
+ data: {
113
+ listProject: [
114
+ {
115
+ versions: [
116
+ { id: testUuid(2), label: 'v1' },
117
+ { id: testUuid(3), label: null },
118
+ ],
119
+ },
120
+ ],
121
+ },
122
+ },
123
+ })
124
+ })
@@ -70,26 +70,26 @@ test('querying post + author name', async () => {
70
70
  {
71
71
  sql: SQL`select
72
72
  "root_"."id" as "root_id",
73
- "root_"."author_id" as "root_author"
73
+ "root_"."author_id" as "root_$key_author"
74
74
  from "public"."post" as "root_"`,
75
75
  parameters: [],
76
76
  response: {
77
77
  rows: [
78
78
  {
79
79
  root_id: testUuid(1),
80
- root_author: testUuid(3),
80
+ 'root_$key_author': testUuid(3),
81
81
  },
82
82
  {
83
83
  root_id: testUuid(2),
84
- root_author: testUuid(4),
84
+ 'root_$key_author': testUuid(4),
85
85
  },
86
86
  ],
87
87
  },
88
88
  },
89
89
  {
90
90
  sql: SQL`SELECT
91
- "root_"."id" AS "root_id",
92
- "root_country"."name" IN (?) AS "root___predicate_countryPredicate",
91
+ "root_"."id" as "root_$index_id",
92
+ "root_country"."name" IN (?) as "root_$predicate_countryPredicate",
93
93
  "root_"."name" AS "root_name",
94
94
  "root_"."id" AS "root_id"
95
95
  FROM "public"."author" AS "root_"
@@ -100,7 +100,8 @@ test('querying post + author name', async () => {
100
100
  rows: [
101
101
  {
102
102
  root_id: testUuid(3),
103
- root___predicate_countryPredicate: true,
103
+ 'root_$index_id': testUuid(3),
104
+ 'root_$predicate_countryPredicate': true,
104
105
  root_name: 'John',
105
106
  },
106
107
  ],