@contember/engine-content-api 2.2.0-alpha.13 → 2.2.0-alpha.15
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.
- package/CLAUDE.md +1 -0
- package/dist/development/src/acl/PermissionFactory.cjs +7 -0
- package/dist/development/src/acl/PermissionFactory.cjs.map +1 -1
- package/dist/development/src/acl/PermissionFactory.js +7 -0
- package/dist/development/src/acl/PermissionFactory.js.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs +1 -0
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js +1 -0
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +1 -0
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +1 -0
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs +1 -0
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js +1 -0
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +1 -0
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs.map +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +1 -0
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
- package/dist/development/src/introspection/IntrospectionSchemaFactory.cjs +11 -6
- package/dist/development/src/introspection/IntrospectionSchemaFactory.cjs.map +1 -1
- package/dist/development/src/introspection/IntrospectionSchemaFactory.js +11 -6
- package/dist/development/src/introspection/IntrospectionSchemaFactory.js.map +1 -1
- package/dist/development/src/mapper/ErrorUtils.cjs +7 -1
- package/dist/development/src/mapper/ErrorUtils.cjs.map +1 -1
- package/dist/development/src/mapper/ErrorUtils.js +7 -1
- package/dist/development/src/mapper/ErrorUtils.js.map +1 -1
- package/dist/development/src/mapper/Mapper.cjs +2 -1
- package/dist/development/src/mapper/Mapper.cjs.map +1 -1
- package/dist/development/src/mapper/Mapper.js +2 -1
- package/dist/development/src/mapper/Mapper.js.map +1 -1
- package/dist/development/src/mapper/select/OrderByBuilder.cjs +3 -2
- package/dist/development/src/mapper/select/OrderByBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/select/OrderByBuilder.js +3 -2
- package/dist/development/src/mapper/select/OrderByBuilder.js.map +1 -1
- package/dist/development/src/mapper/select/OrderByHelper.cjs +17 -7
- package/dist/development/src/mapper/select/OrderByHelper.cjs.map +1 -1
- package/dist/development/src/mapper/select/OrderByHelper.js +17 -7
- package/dist/development/src/mapper/select/OrderByHelper.js.map +1 -1
- package/dist/development/src/mapper/select/Path.cjs +23 -3
- package/dist/development/src/mapper/select/Path.cjs.map +1 -1
- package/dist/development/src/mapper/select/Path.js +23 -3
- package/dist/development/src/mapper/select/Path.js.map +1 -1
- package/dist/development/src/mapper/select/RelationFetcher.cjs +1 -1
- package/dist/development/src/mapper/select/RelationFetcher.cjs.map +1 -1
- package/dist/development/src/mapper/select/RelationFetcher.js +1 -1
- package/dist/development/src/mapper/select/RelationFetcher.js.map +1 -1
- package/dist/development/src/mapper/select/SelectBuilder.cjs +5 -5
- package/dist/development/src/mapper/select/SelectBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/select/SelectBuilder.js +5 -5
- package/dist/development/src/mapper/select/SelectBuilder.js.map +1 -1
- package/dist/development/src/mapper/select/handlers/FieldsVisitor.cjs +1 -1
- package/dist/development/src/mapper/select/handlers/FieldsVisitor.cjs.map +1 -1
- package/dist/development/src/mapper/select/handlers/FieldsVisitor.js +1 -1
- package/dist/development/src/mapper/select/handlers/FieldsVisitor.js.map +1 -1
- package/dist/development/src/resolvers/MutationResolver.cjs +1 -0
- package/dist/development/src/resolvers/MutationResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/MutationResolver.js +1 -0
- package/dist/development/src/resolvers/MutationResolver.js.map +1 -1
- package/dist/development/src/resolvers/ReadHelpers.cjs +1 -0
- package/dist/development/src/resolvers/ReadHelpers.cjs.map +1 -1
- package/dist/development/src/resolvers/ReadHelpers.js +1 -0
- package/dist/development/src/resolvers/ReadHelpers.js.map +1 -1
- package/dist/development/src/resolvers/ReadResolver.cjs +21 -7
- package/dist/development/src/resolvers/ReadResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/ReadResolver.js +21 -7
- package/dist/development/src/resolvers/ReadResolver.js.map +1 -1
- package/dist/development/src/schema/GraphQlSchemaBuilderFactory.cjs +1 -0
- package/dist/development/src/schema/GraphQlSchemaBuilderFactory.cjs.map +1 -1
- package/dist/development/src/schema/GraphQlSchemaBuilderFactory.js +1 -0
- package/dist/development/src/schema/GraphQlSchemaBuilderFactory.js.map +1 -1
- package/dist/production/src/acl/PermissionFactory.cjs +7 -0
- package/dist/production/src/acl/PermissionFactory.cjs.map +1 -1
- package/dist/production/src/acl/PermissionFactory.js +7 -0
- package/dist/production/src/acl/PermissionFactory.js.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs +1 -0
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.cjs.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js +1 -0
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +1 -0
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +1 -0
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs +1 -0
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.cjs.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js +1 -0
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +1 -0
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs.map +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +1 -0
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
- package/dist/production/src/introspection/IntrospectionSchemaFactory.cjs +11 -6
- package/dist/production/src/introspection/IntrospectionSchemaFactory.cjs.map +1 -1
- package/dist/production/src/introspection/IntrospectionSchemaFactory.js +11 -6
- package/dist/production/src/introspection/IntrospectionSchemaFactory.js.map +1 -1
- package/dist/production/src/mapper/ErrorUtils.cjs +7 -1
- package/dist/production/src/mapper/ErrorUtils.cjs.map +1 -1
- package/dist/production/src/mapper/ErrorUtils.js +7 -1
- package/dist/production/src/mapper/ErrorUtils.js.map +1 -1
- package/dist/production/src/mapper/Mapper.cjs +2 -1
- package/dist/production/src/mapper/Mapper.cjs.map +1 -1
- package/dist/production/src/mapper/Mapper.js +2 -1
- package/dist/production/src/mapper/Mapper.js.map +1 -1
- package/dist/production/src/mapper/select/OrderByBuilder.cjs +3 -2
- package/dist/production/src/mapper/select/OrderByBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/select/OrderByBuilder.js +3 -2
- package/dist/production/src/mapper/select/OrderByBuilder.js.map +1 -1
- package/dist/production/src/mapper/select/OrderByHelper.cjs +17 -7
- package/dist/production/src/mapper/select/OrderByHelper.cjs.map +1 -1
- package/dist/production/src/mapper/select/OrderByHelper.js +17 -7
- package/dist/production/src/mapper/select/OrderByHelper.js.map +1 -1
- package/dist/production/src/mapper/select/Path.cjs +23 -3
- package/dist/production/src/mapper/select/Path.cjs.map +1 -1
- package/dist/production/src/mapper/select/Path.js +23 -3
- package/dist/production/src/mapper/select/Path.js.map +1 -1
- package/dist/production/src/mapper/select/RelationFetcher.cjs +1 -1
- package/dist/production/src/mapper/select/RelationFetcher.cjs.map +1 -1
- package/dist/production/src/mapper/select/RelationFetcher.js +1 -1
- package/dist/production/src/mapper/select/RelationFetcher.js.map +1 -1
- package/dist/production/src/mapper/select/SelectBuilder.cjs +5 -5
- package/dist/production/src/mapper/select/SelectBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/select/SelectBuilder.js +5 -5
- package/dist/production/src/mapper/select/SelectBuilder.js.map +1 -1
- package/dist/production/src/mapper/select/handlers/FieldsVisitor.cjs +1 -1
- package/dist/production/src/mapper/select/handlers/FieldsVisitor.cjs.map +1 -1
- package/dist/production/src/mapper/select/handlers/FieldsVisitor.js +1 -1
- package/dist/production/src/mapper/select/handlers/FieldsVisitor.js.map +1 -1
- package/dist/production/src/resolvers/MutationResolver.cjs +1 -0
- package/dist/production/src/resolvers/MutationResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/MutationResolver.js +1 -0
- package/dist/production/src/resolvers/MutationResolver.js.map +1 -1
- package/dist/production/src/resolvers/ReadHelpers.cjs +1 -0
- package/dist/production/src/resolvers/ReadHelpers.cjs.map +1 -1
- package/dist/production/src/resolvers/ReadHelpers.js +1 -0
- package/dist/production/src/resolvers/ReadHelpers.js.map +1 -1
- package/dist/production/src/resolvers/ReadResolver.cjs +21 -7
- package/dist/production/src/resolvers/ReadResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/ReadResolver.js +21 -7
- package/dist/production/src/resolvers/ReadResolver.js.map +1 -1
- package/dist/production/src/schema/GraphQlSchemaBuilderFactory.cjs +1 -0
- package/dist/production/src/schema/GraphQlSchemaBuilderFactory.cjs.map +1 -1
- package/dist/production/src/schema/GraphQlSchemaBuilderFactory.js +1 -0
- package/dist/production/src/schema/GraphQlSchemaBuilderFactory.js.map +1 -1
- package/dist/tests/cases/unit/introspectionAcl.test.d.ts +2 -0
- package/dist/tests/cases/unit/introspectionAcl.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/mutationSqlError.test.d.ts +2 -0
- package/dist/tests/cases/unit/mutationSqlError.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/pathAlias.test.d.ts +2 -0
- package/dist/tests/cases/unit/pathAlias.test.d.ts.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/acl/PermissionFactory.d.ts +2 -0
- package/dist/types/acl/PermissionFactory.d.ts.map +1 -1
- package/dist/types/introspection/IntrospectionSchemaFactory.d.ts.map +1 -1
- package/dist/types/mapper/ErrorUtils.d.ts.map +1 -1
- package/dist/types/mapper/select/OrderByBuilder.d.ts.map +1 -1
- package/dist/types/mapper/select/OrderByHelper.d.ts +2 -0
- package/dist/types/mapper/select/OrderByHelper.d.ts.map +1 -1
- package/dist/types/mapper/select/Path.d.ts +1 -0
- package/dist/types/mapper/select/Path.d.ts.map +1 -1
- package/dist/types/mapper/select/RelationFetcher.d.ts.map +1 -1
- package/dist/types/mapper/select/SelectBuilder.d.ts.map +1 -1
- package/dist/types/resolvers/ReadResolver.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/acl/PermissionFactory.ts +9 -0
- package/src/introspection/IntrospectionSchemaFactory.ts +13 -6
- package/src/mapper/ErrorUtils.ts +11 -1
- package/src/mapper/Mapper.ts +1 -1
- package/src/mapper/select/OrderByBuilder.ts +3 -2
- package/src/mapper/select/OrderByHelper.ts +19 -10
- package/src/mapper/select/Path.ts +25 -5
- package/src/mapper/select/RelationFetcher.ts +1 -4
- package/src/mapper/select/SelectBuilder.ts +5 -4
- package/src/mapper/select/handlers/FieldsVisitor.ts +1 -1
- package/src/resolvers/ReadResolver.ts +24 -7
- package/tests/cases/bugs/bug102.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/delete/deleteById.test.ts +4 -3
- package/tests/cases/integration/graphQlRequests/query/acl/differentRowAndFieldPredicate.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.ts +12 -10
- package/tests/cases/integration/graphQlRequests/query/acl/metaReadableThroughContext.test.ts +15 -15
- package/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.ts +7 -6
- package/tests/cases/integration/graphQlRequests/query/acl/nonAdjacentBackReference.test.ts +6 -6
- package/tests/cases/integration/graphQlRequests/query/acl/orderByCellPredicate.test.ts +6 -6
- package/tests/cases/integration/graphQlRequests/query/acl/predicateElimination.test.ts +25 -23
- package/tests/cases/integration/graphQlRequests/query/acl/relationAcl.test.ts +12 -9
- package/tests/cases/integration/graphQlRequests/query/acl/rowPredicateSubset.test.ts +6 -6
- package/tests/cases/integration/graphQlRequests/query/acl/throughScope.test.ts +14 -12
- package/tests/cases/integration/graphQlRequests/query/acl/throughScopeNullability.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/query/filter/backReferencedFilter.test.ts +3 -1
- package/tests/cases/integration/graphQlRequests/query/graphqlFeatures/alias.test.ts +2 -2
- package/tests/cases/integration/graphQlRequests/query/graphqlFeatures/fragments.test.ts +8 -8
- package/tests/cases/integration/graphQlRequests/query/misc/reducedHasMany.test.ts +10 -10
- package/tests/cases/integration/graphQlRequests/query/pagination/hasManyLimit.test.ts +8 -8
- package/tests/cases/integration/graphQlRequests/query/pagination/paginate.test.ts +5 -4
- package/tests/cases/integration/graphQlRequests/query/pagination/paginateAliased.test.ts +5 -4
- package/tests/cases/integration/graphQlRequests/query/relations/advanced.test.ts +17 -8
- package/tests/cases/integration/graphQlRequests/query/relations/manyHasManyInverse.test.ts +6 -6
- package/tests/cases/integration/graphQlRequests/query/relations/manyHasManyOwning.test.ts +6 -6
- package/tests/cases/integration/graphQlRequests/query/relations/manyHasOne.test.ts +12 -9
- package/tests/cases/integration/graphQlRequests/query/relations/oneHasMany.test.ts +12 -12
- package/tests/cases/integration/graphQlRequests/query/relations/oneHasOneInverse.test.ts +6 -4
- package/tests/cases/integration/graphQlRequests/query/relations/oneHasOneOwner.test.ts +6 -4
- package/tests/cases/integration/graphQlRequests/query/sorting/defaultOrdering.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/query/sorting/randomSort.test.ts +107 -3
- package/tests/cases/integration/graphQlRequests/query/sorting/sortedHasMany.test.ts +2 -2
- package/tests/cases/integration/graphQlRequests/query/view/view.test.ts +6 -6
- package/tests/cases/unit/introspectionAcl.test.ts +30 -0
- package/tests/cases/unit/mutationSqlError.test.ts +30 -0
- package/tests/cases/unit/pathAlias.test.ts +26 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/engine-content-api",
|
|
3
|
-
"version": "2.2.0-alpha.
|
|
3
|
+
"version": "2.2.0-alpha.15",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/production/index.js",
|
|
6
6
|
"typings": "./dist/types/index.d.ts",
|
|
@@ -26,17 +26,17 @@
|
|
|
26
26
|
"generate": "gql-gen --config graphql.codegen.yml"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@contember/database": "2.2.0-alpha.
|
|
30
|
-
"@contember/dic": "2.2.0-alpha.
|
|
31
|
-
"@contember/graphql-utils": "2.2.0-alpha.
|
|
32
|
-
"@contember/logger": "2.2.0-alpha.
|
|
33
|
-
"@contember/schema": "2.2.0-alpha.
|
|
34
|
-
"@contember/schema-definition": "2.2.0-alpha.
|
|
35
|
-
"@contember/schema-utils": "2.2.0-alpha.
|
|
29
|
+
"@contember/database": "2.2.0-alpha.15",
|
|
30
|
+
"@contember/dic": "2.2.0-alpha.15",
|
|
31
|
+
"@contember/graphql-utils": "2.2.0-alpha.15",
|
|
32
|
+
"@contember/logger": "2.2.0-alpha.15",
|
|
33
|
+
"@contember/schema": "2.2.0-alpha.15",
|
|
34
|
+
"@contember/schema-definition": "2.2.0-alpha.15",
|
|
35
|
+
"@contember/schema-utils": "2.2.0-alpha.15",
|
|
36
36
|
"fast-deep-equal": "^3.1.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@contember/database-tester": "2.2.0-alpha.
|
|
39
|
+
"@contember/database-tester": "2.2.0-alpha.15",
|
|
40
40
|
"@types/node": "^24.12.0",
|
|
41
41
|
"graphql": "^16.13.1",
|
|
42
42
|
"pg": "^8.20.0"
|
|
@@ -23,6 +23,15 @@ export class PermissionFactory {
|
|
|
23
23
|
return this.createInternal(schema, roles, scope, prefix)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/** The role-level `content.refreshMaterializedView` of the given roles, including the roles they inherit. */
|
|
27
|
+
public isRefreshMaterializedViewAllowed(schema: Schema, roles: readonly string[]): boolean {
|
|
28
|
+
return roles.some(role => {
|
|
29
|
+
const roleDefinition = schema.acl.roles[role]
|
|
30
|
+
return roleDefinition?.content?.refreshMaterializedView === true
|
|
31
|
+
|| this.isRefreshMaterializedViewAllowed(schema, roleDefinition?.inherits ?? [])
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
26
35
|
public createContextual(schema: Schema, roles: readonly string[]): ContextualPermissions {
|
|
27
36
|
return {
|
|
28
37
|
root: this.createInternal(schema, roles, 'root'),
|
|
@@ -154,12 +154,19 @@ export class IntrospectionSchemaFactory {
|
|
|
154
154
|
public create(): ContentSchema._Schema {
|
|
155
155
|
const entities = Object.values(this.model.entities)
|
|
156
156
|
.filter(it => this.authorizator.getEntityPermission(Acl.Operation.read, it.name) !== 'no')
|
|
157
|
-
.map(entity =>
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
157
|
+
.map(entity => {
|
|
158
|
+
const fields = this.createFieldsSchema(entity.name)
|
|
159
|
+
const readableFields = new Set(fields.map(it => it.name))
|
|
160
|
+
return {
|
|
161
|
+
name: entity.name,
|
|
162
|
+
customPrimaryAllowed: this.authorizator.isCustomPrimaryAllowed(entity.name),
|
|
163
|
+
fields,
|
|
164
|
+
// a constraint over an unreadable field would disclose that field's name
|
|
165
|
+
unique: Object.values(entity.unique)
|
|
166
|
+
.filter(({ fields }) => fields.every(it => readableFields.has(it)))
|
|
167
|
+
.map(({ fields }) => ({ fields })),
|
|
168
|
+
}
|
|
169
|
+
})
|
|
163
170
|
const usedEnums = new Set(
|
|
164
171
|
entities
|
|
165
172
|
.flatMap(it => it.fields)
|
package/src/mapper/ErrorUtils.ts
CHANGED
|
@@ -142,13 +142,23 @@ export const convertError = (
|
|
|
142
142
|
if (e instanceof Database.TransactionAbortedError) {
|
|
143
143
|
return new MutationSqlError([], e.originalMessage, [MutationResultHint.subSequentSqlError])
|
|
144
144
|
}
|
|
145
|
-
if (e instanceof Database.
|
|
145
|
+
if (e instanceof Database.CannotCommitError) {
|
|
146
146
|
logger.error(e, { loc: 'convertError' })
|
|
147
147
|
return new MutationSqlError([], e.originalMessage, [MutationResultHint.sqlError])
|
|
148
148
|
}
|
|
149
|
+
if (e instanceof Database.QueryError) {
|
|
150
|
+
logger.error(e, { loc: 'convertError' })
|
|
151
|
+
const message = hasClientFacingMessage(e.code) ? e.originalMessage : 'Database query failed'
|
|
152
|
+
return new MutationSqlError([], message, [MutationResultHint.sqlError])
|
|
153
|
+
}
|
|
149
154
|
throw e
|
|
150
155
|
}
|
|
151
156
|
|
|
157
|
+
// Data (22) and integrity (23) errors and project trigger exceptions (P0001) carry messages clients act on. Other
|
|
158
|
+
// messages (e.g. class 42) can quote internal SQL identifiers.
|
|
159
|
+
const hasClientFacingMessage = (code: string | undefined): boolean =>
|
|
160
|
+
code !== undefined && (code.startsWith('22') || code.startsWith('23') || code === 'P0001')
|
|
161
|
+
|
|
152
162
|
export const tryMutation = async (
|
|
153
163
|
schema: Model.Schema,
|
|
154
164
|
databaseMetadata: DatabaseMetadata,
|
package/src/mapper/Mapper.ts
CHANGED
|
@@ -79,7 +79,7 @@ export class Mapper<ConnectionType extends Connection.ConnectionLike = Connectio
|
|
|
79
79
|
): Promise<SelectIndexedResultObjects> {
|
|
80
80
|
const hydrator = new SelectHydrator(this.memoryBudget)
|
|
81
81
|
const path = this.pathFactory.create([])
|
|
82
|
-
const indexByAlias: string = path.for(indexBy).alias
|
|
82
|
+
const indexByAlias: string = path.forInternal('index').for(indexBy).alias
|
|
83
83
|
const qb: SelectBuilder = SelectBuilder.create()
|
|
84
84
|
.select([path.alias, getColumnName(this.schema, entity, indexBy)], indexByAlias)
|
|
85
85
|
const rows = await this.selectRows(hydrator, qb, entity, input, relationPath)
|
|
@@ -7,6 +7,7 @@ import { UserError } from '../../exception.js'
|
|
|
7
7
|
import { PredicateFactory, PredicatesInjector } from '../../acl/index.js'
|
|
8
8
|
import { WhereBuilder } from './WhereBuilder.js'
|
|
9
9
|
import { WhereOptimizer } from './optimizer/WhereOptimizer.js'
|
|
10
|
+
import { OrderByHelper } from './OrderByHelper.js'
|
|
10
11
|
|
|
11
12
|
const orderByMapping = {
|
|
12
13
|
asc: 'asc',
|
|
@@ -65,8 +66,8 @@ export class OrderByBuilder {
|
|
|
65
66
|
const fields = entries.map(it => it[0]).join(', ')
|
|
66
67
|
throw new UserError('Order by: only one field is expected in each item of order by clause, got: ' + fields)
|
|
67
68
|
}
|
|
68
|
-
if (
|
|
69
|
-
if (orderBy._randomSeeded) {
|
|
69
|
+
if (OrderByHelper.isRandomOrder(orderBy)) {
|
|
70
|
+
if (orderBy._randomSeeded !== undefined) {
|
|
70
71
|
const seed = orderBy._randomSeeded / Math.pow(2, 31)
|
|
71
72
|
if (seed < -1 || seed > 1) {
|
|
72
73
|
throw new UserError(`Order by: random seed must be in range of 32bit signed integer`)
|
|
@@ -7,24 +7,33 @@ export class OrderByHelper {
|
|
|
7
7
|
objectNode: ObjectNode<Input.ListQueryInput>,
|
|
8
8
|
relationOrderBy: readonly Model.OrderBy[] | undefined,
|
|
9
9
|
): ObjectNode<Input.ListQueryInput> {
|
|
10
|
-
const
|
|
10
|
+
const requestedOrder = objectNode.args.orderBy || []
|
|
11
|
+
const inputOrder = requestedOrder.filter(it => !this.isEmptyRandomOrder(it))
|
|
12
|
+
const inputNode = inputOrder.length === requestedOrder.length ? objectNode : objectNode.withArg('orderBy', inputOrder)
|
|
11
13
|
const hasOrderBy = inputOrder.length > 0
|
|
12
14
|
const defaultOrderBy = relationOrderBy ?? entity.orderBy ?? []
|
|
13
15
|
if (!hasOrderBy && defaultOrderBy.length > 0) {
|
|
14
16
|
const defaultOrderByWithPrimary = [...defaultOrderBy, ...this.getPrimaryOrderBy(inputOrder, entity)]
|
|
15
|
-
return
|
|
17
|
+
return inputNode.withArg('orderBy', this.buildOrderBy(defaultOrderByWithPrimary))
|
|
16
18
|
}
|
|
17
|
-
const hasLimit = typeof
|
|
18
|
-
const hasOffset = typeof
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|| (hasOrderBy && (inputOrder[0]._random || inputOrder[0]._randomSeeded !== undefined))
|
|
22
|
-
) {
|
|
23
|
-
return objectNode
|
|
19
|
+
const hasLimit = typeof inputNode.args.limit === 'number'
|
|
20
|
+
const hasOffset = typeof inputNode.args.offset === 'number'
|
|
21
|
+
if ((!hasLimit && !hasOffset && !hasOrderBy) || (hasOrderBy && this.isRandomOrder(inputOrder[0]))) {
|
|
22
|
+
return inputNode
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
const orderBy = this.buildOrderBy(this.getPrimaryOrderBy(inputOrder, entity))
|
|
27
|
-
return
|
|
26
|
+
return inputNode.withArg('orderBy', [...inputOrder, ...orderBy])
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public static isRandomOrder(orderBy: Input.OrderBy): boolean {
|
|
30
|
+
return orderBy._random === true || typeof orderBy._randomSeeded === 'number'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// GraphQL passes `{ _random: null }`, `{ _random: false }` and `{ _randomSeeded: null }` through; they order nothing.
|
|
34
|
+
private static isEmptyRandomOrder(orderBy: Input.OrderBy): boolean {
|
|
35
|
+
const keys = Object.keys(orderBy)
|
|
36
|
+
return keys.length === 1 && (keys[0] === '_random' || keys[0] === '_randomSeeded') && !this.isRandomOrder(orderBy)
|
|
28
37
|
}
|
|
29
38
|
|
|
30
39
|
private static buildOrderBy(defaultOrderBy: readonly Model.OrderBy[]): Input.OrderByFields[] {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const MAX_IDENTIFIER_LENGTH = 63
|
|
2
2
|
|
|
3
|
+
const utf8Encoder = new TextEncoder()
|
|
4
|
+
const byteLength = (value: string): number => utf8Encoder.encode(value).length
|
|
5
|
+
|
|
3
6
|
export type HopGuards = { readonly row: boolean; readonly field: boolean }
|
|
4
7
|
|
|
5
8
|
/**
|
|
@@ -58,14 +61,31 @@ export class Path {
|
|
|
58
61
|
return new Path([...this.path, path], this.aliasContext, this.rootAlias)
|
|
59
62
|
}
|
|
60
63
|
|
|
64
|
+
// Segment for a column the engine selects for itself. `$` cannot occur in a GraphQL alias, so these aliases stay
|
|
65
|
+
// distinct from those of selected fields; `kind` must not contain `_`.
|
|
66
|
+
public forInternal(kind: string) {
|
|
67
|
+
return this.for('$' + kind)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// PostgreSQL limits identifiers in bytes. Untruncated aliases stay below the limit and truncated ones fill it
|
|
71
|
+
// exactly (padded when a multi-byte character does not fit), so the two can never coincide.
|
|
61
72
|
private createAlias(): string {
|
|
62
73
|
const alias = this.fullAlias
|
|
63
|
-
|
|
64
|
-
// intentionally not allowing == MAX_IDENTIFIER_LENGTH
|
|
65
|
-
if (alias.length < MAX_IDENTIFIER_LENGTH) {
|
|
74
|
+
if (byteLength(alias) < MAX_IDENTIFIER_LENGTH) {
|
|
66
75
|
return alias
|
|
67
76
|
}
|
|
68
|
-
const
|
|
69
|
-
|
|
77
|
+
const suffix = '_' + this.aliasContext.getAliasIndex(alias).toString()
|
|
78
|
+
const prefixBytes = MAX_IDENTIFIER_LENGTH - suffix.length
|
|
79
|
+
let prefix = ''
|
|
80
|
+
let usedBytes = 0
|
|
81
|
+
for (const char of alias) {
|
|
82
|
+
const charBytes = byteLength(char)
|
|
83
|
+
if (usedBytes + charBytes > prefixBytes) {
|
|
84
|
+
break
|
|
85
|
+
}
|
|
86
|
+
prefix += char
|
|
87
|
+
usedBytes += charBytes
|
|
88
|
+
}
|
|
89
|
+
return prefix + '_'.repeat(prefixBytes - usedBytes) + suffix
|
|
70
90
|
}
|
|
71
91
|
}
|
|
@@ -272,10 +272,7 @@ export class RelationFetcher {
|
|
|
272
272
|
|
|
273
273
|
const where = this.predicateInjector.inject(targetEntity, objectArgs.filter || {}, 'nested', relationPath[relationPath.length - 1])
|
|
274
274
|
const hasWhere = where && Object.keys(where).length > 0
|
|
275
|
-
const hasFieldOrderBy = objectArgs.orderBy
|
|
276
|
-
&& objectArgs.orderBy.length > 0
|
|
277
|
-
&& !objectArgs.orderBy[0]._random
|
|
278
|
-
&& objectArgs.orderBy[0]._randomSeeded === undefined
|
|
275
|
+
const hasFieldOrderBy = objectArgs.orderBy?.some(it => !OrderByHelper.isRandomOrder(it)) ?? false
|
|
279
276
|
|
|
280
277
|
if (hasWhere || hasFieldOrderBy) {
|
|
281
278
|
const path = this.pathFactory.create([])
|
|
@@ -91,7 +91,7 @@ export class SelectBuilder {
|
|
|
91
91
|
if (typeof predicate === 'boolean') {
|
|
92
92
|
return () => predicate
|
|
93
93
|
}
|
|
94
|
-
const predicatePath = path.
|
|
94
|
+
const predicatePath = path.forInternal('predicate').for(predicate)
|
|
95
95
|
|
|
96
96
|
if (!fetchedPredicates.has(predicate)) {
|
|
97
97
|
const primaryPredicate = this.predicateFactory.createReadPredicate(entity, undefined, this.relationPath)
|
|
@@ -132,8 +132,8 @@ export class SelectBuilder {
|
|
|
132
132
|
}
|
|
133
133
|
const predicateGetter = predicate !== undefined && predicate !== true ? addPredicate(predicate) : null
|
|
134
134
|
const columnName = getColumnName(this.schema, entity, field)
|
|
135
|
-
const parentValuePath = path.for(field)
|
|
136
|
-
let ids = await this.getColumnValues(parentValuePath, columnName, predicateGetter)
|
|
135
|
+
const parentValuePath = path.forInternal('key').for(field)
|
|
136
|
+
let ids = await this.getColumnValues(path, parentValuePath, columnName, predicateGetter)
|
|
137
137
|
|
|
138
138
|
const data = ids.length > 0 ? dataProvider(ids) : Promise.resolve({})
|
|
139
139
|
this.hydrator.addPromise(
|
|
@@ -188,11 +188,12 @@ export class SelectBuilder {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
private async getColumnValues(
|
|
191
|
+
tablePath: Path,
|
|
191
192
|
columnPath: Path,
|
|
192
193
|
columnName: string,
|
|
193
194
|
predicateGetter: null | ColumnValueGetter<boolean>,
|
|
194
195
|
): Promise<Input.PrimaryValue[]> {
|
|
195
|
-
this.qb = this.qb.select([
|
|
196
|
+
this.qb = this.qb.select([tablePath.alias, columnName], columnPath.alias)
|
|
196
197
|
const rows = await this.rows
|
|
197
198
|
const filteredRows = predicateGetter === null ? rows : rows.filter(predicateGetter)
|
|
198
199
|
const columnAlias = columnPath.alias
|
|
@@ -60,7 +60,7 @@ export class FieldsVisitor implements Model.RelationByTypeVisitor<void>, Model.C
|
|
|
60
60
|
const aliases: string[] = []
|
|
61
61
|
for (const source of entity.view.idSource) {
|
|
62
62
|
const columnName = getColumnName(this.schema, entity, source)
|
|
63
|
-
const idSrcPath = columnPath.
|
|
63
|
+
const idSrcPath = columnPath.forInternal('idSrc').for(source)
|
|
64
64
|
aliases.push(idSrcPath.alias)
|
|
65
65
|
this.executionContext.addColumn({
|
|
66
66
|
query: qb => qb.select([tableAlias, columnName], idSrcPath.alias),
|
|
@@ -4,6 +4,8 @@ import { GraphQLResolveInfo } from 'graphql'
|
|
|
4
4
|
import { GraphQlQueryAstFactory } from './GraphQlQueryAstFactory.js'
|
|
5
5
|
import { ObjectNode } from '../inputProcessing/index.js'
|
|
6
6
|
import { executeReadOperations, paginate } from './ReadHelpers.js'
|
|
7
|
+
import { InvalidDataError } from '@contember/database'
|
|
8
|
+
import { UserError } from '../exception.js'
|
|
7
9
|
|
|
8
10
|
export class ReadResolver {
|
|
9
11
|
constructor(
|
|
@@ -15,31 +17,46 @@ export class ReadResolver {
|
|
|
15
17
|
const queryAst = this.queryAstFactory.create(info)
|
|
16
18
|
const fields = GraphQlQueryAstFactory.resolveObjectType(info.returnType).getFields()
|
|
17
19
|
const mapper = this.mapperFactory.create()
|
|
18
|
-
return executeReadOperations(queryAst, fields, mapper)
|
|
20
|
+
return await withInvalidDataAsUserError(() => executeReadOperations(queryAst, fields, mapper))
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
public async resolveTransaction(info: GraphQLResolveInfo) {
|
|
22
24
|
const queryAst = this.queryAstFactory.create(info)
|
|
23
25
|
const fields = GraphQlQueryAstFactory.resolveObjectType(info.returnType).getFields()
|
|
24
26
|
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
return await withInvalidDataAsUserError(() =>
|
|
28
|
+
this.mapperFactory.transaction(async mapper => {
|
|
29
|
+
return executeReadOperations(queryAst, fields, mapper)
|
|
30
|
+
})
|
|
31
|
+
)
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
public async resolveListQuery(entity: Model.Entity, info: GraphQLResolveInfo) {
|
|
31
35
|
const queryAst: ObjectNode<Input.ListQueryInput> = this.queryAstFactory.create(info)
|
|
32
|
-
return await this.mapperFactory.create().select(entity, queryAst, [])
|
|
36
|
+
return await withInvalidDataAsUserError(() => this.mapperFactory.create().select(entity, queryAst, []))
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
public async resolveGetQuery(entity: Model.Entity, info: GraphQLResolveInfo) {
|
|
36
40
|
const queryAst: ObjectNode<Input.UniqueQueryInput> = this.queryAstFactory.create(info)
|
|
37
|
-
return await this.mapperFactory.create().selectUnique(entity, queryAst, [])
|
|
41
|
+
return await withInvalidDataAsUserError(() => this.mapperFactory.create().selectUnique(entity, queryAst, []))
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
public async resolvePaginationQuery(entity: Model.Entity, info: GraphQLResolveInfo) {
|
|
41
45
|
const queryAst: ObjectNode<Input.PaginationQueryInput> = this.queryAstFactory.create(info)
|
|
42
46
|
const mapper = this.mapperFactory.create()
|
|
43
|
-
return await paginate(mapper, entity, queryAst)
|
|
47
|
+
return await withInvalidDataAsUserError(() => paginate(mapper, entity, queryAst))
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// A filter value PostgreSQL cannot parse is a client input error, as convertError reports it for mutations.
|
|
52
|
+
// Reads issued inside a mutation (its result nodes, `transaction { query }`) do not pass through here.
|
|
53
|
+
const withInvalidDataAsUserError = async <T>(cb: () => Promise<T>): Promise<T> => {
|
|
54
|
+
try {
|
|
55
|
+
return await cb()
|
|
56
|
+
} catch (e) {
|
|
57
|
+
if (e instanceof InvalidDataError) {
|
|
58
|
+
throw new UserError(e.originalMessage, { cause: e })
|
|
59
|
+
}
|
|
60
|
+
throw e
|
|
44
61
|
}
|
|
45
62
|
}
|
|
@@ -43,23 +43,23 @@ test('Filter by has many with additional join', async () => {
|
|
|
43
43
|
executes: [
|
|
44
44
|
{
|
|
45
45
|
sql: SQL`
|
|
46
|
-
select "root_"."id" as "root_id", "root_"."short_name" as "root_shortName", "root_"."id" as "
|
|
46
|
+
select "root_"."id" as "root_id", "root_"."short_name" as "root_shortName", "root_"."id" as "root_$key_id"
|
|
47
47
|
from "public"."person" as "root_"
|
|
48
48
|
where exists (select 1
|
|
49
49
|
from "public"."person_locale" as "root_locales"
|
|
50
50
|
left join "public"."language" as "root_locales_locale" on "root_locales"."locale_id" = "root_locales_locale"."id"
|
|
51
51
|
where "root_"."id" = "root_locales"."person_id" and "root_locales_locale"."slug" = ? and not("root_locales"."url_slug" is null))`,
|
|
52
|
-
response: { rows: [{ root_id: testUuid(1), root_shortName: 'John' }] },
|
|
52
|
+
response: { rows: [{ root_id: testUuid(1), 'root_$key_id': testUuid(1), root_shortName: 'John' }] },
|
|
53
53
|
parameters: ['cs'],
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
|
-
sql: SQL`select "root_"."person_id" as "
|
|
56
|
+
sql: SQL`select "root_"."person_id" as "root_$index_person", "root_"."url_slug" as "root_urlSlug", "root_"."id" as "root_id"
|
|
57
57
|
from "public"."person_locale" as "root_"
|
|
58
58
|
left join "public"."language" as "root_locale" on "root_"."locale_id" = "root_locale"."id"
|
|
59
59
|
where "root_locale"."slug" = ? and "root_"."person_id" in (?)`,
|
|
60
60
|
parameters: ['cs', testUuid(1)],
|
|
61
61
|
response: {
|
|
62
|
-
rows: [{
|
|
62
|
+
rows: [{ 'root_$index_person': testUuid(1), root_urlSlug: 'john', root_id: testUuid(2) }],
|
|
63
63
|
},
|
|
64
64
|
},
|
|
65
65
|
],
|
|
@@ -27,7 +27,7 @@ test('delete post by id', async () => {
|
|
|
27
27
|
{
|
|
28
28
|
sql: SQL`select
|
|
29
29
|
"root_"."id" as "root_id",
|
|
30
|
-
"root_"."author_id" as "
|
|
30
|
+
"root_"."author_id" as "root_$key_author"
|
|
31
31
|
from "public"."post" as "root_"
|
|
32
32
|
where "root_"."id" = ?`,
|
|
33
33
|
parameters: [testUuid(1)],
|
|
@@ -35,14 +35,14 @@ test('delete post by id', async () => {
|
|
|
35
35
|
rows: [
|
|
36
36
|
{
|
|
37
37
|
root_id: testUuid(1),
|
|
38
|
-
|
|
38
|
+
'root_$key_author': testUuid(2),
|
|
39
39
|
},
|
|
40
40
|
],
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
sql: SQL`select
|
|
45
|
-
"root_"."id" as "
|
|
45
|
+
"root_"."id" as "root_$index_id",
|
|
46
46
|
"root_"."name" as "root_name",
|
|
47
47
|
"root_"."id" as "root_id"
|
|
48
48
|
from "public"."author" as "root_"
|
|
@@ -52,6 +52,7 @@ test('delete post by id', async () => {
|
|
|
52
52
|
rows: [
|
|
53
53
|
{
|
|
54
54
|
root_id: testUuid(2),
|
|
55
|
+
'root_$index_id': testUuid(2),
|
|
55
56
|
root_name: 'John',
|
|
56
57
|
},
|
|
57
58
|
],
|
package/tests/cases/integration/graphQlRequests/query/acl/differentRowAndFieldPredicate.test.ts
CHANGED
|
@@ -43,7 +43,7 @@ test('different predicate on row and field level', async () => {
|
|
|
43
43
|
sql: SQL`
|
|
44
44
|
select
|
|
45
45
|
"root_"."id" as "root_id",
|
|
46
|
-
"root_"."username" = ? as "
|
|
46
|
+
"root_"."username" = ? as "root_$predicate_authorPredicate",
|
|
47
47
|
"root_"."username" as "root_username"
|
|
48
48
|
from "public"."author" as "root_" where not("root_"."username" is null)
|
|
49
49
|
`,
|
|
@@ -52,7 +52,7 @@ test('different predicate on row and field level', async () => {
|
|
|
52
52
|
rows: [
|
|
53
53
|
{
|
|
54
54
|
root_id: testUuid(1),
|
|
55
|
-
|
|
55
|
+
'root_$predicate_authorPredicate': true,
|
|
56
56
|
root_username: 'johndoe',
|
|
57
57
|
},
|
|
58
58
|
],
|
|
@@ -89,7 +89,7 @@ test('different predicate on row and field level - false', async () => {
|
|
|
89
89
|
sql: SQL`
|
|
90
90
|
select
|
|
91
91
|
"root_"."id" as "root_id",
|
|
92
|
-
"root_"."username" = ? as "
|
|
92
|
+
"root_"."username" = ? as "root_$predicate_authorPredicate",
|
|
93
93
|
"root_"."username" as "root_username"
|
|
94
94
|
from "public"."author" as "root_" where not("root_"."username" is null)
|
|
95
95
|
`,
|
|
@@ -98,7 +98,7 @@ test('different predicate on row and field level - false', async () => {
|
|
|
98
98
|
rows: [
|
|
99
99
|
{
|
|
100
100
|
root_id: testUuid(1),
|
|
101
|
-
|
|
101
|
+
'root_$predicate_authorPredicate': false,
|
|
102
102
|
root_username: 'johndoe',
|
|
103
103
|
},
|
|
104
104
|
],
|
|
@@ -64,7 +64,7 @@ test('querying id and title', async () => {
|
|
|
64
64
|
{
|
|
65
65
|
sql: SQL`SELECT
|
|
66
66
|
"root_"."id" AS "root_id",
|
|
67
|
-
"root_"."locale" IN (?)
|
|
67
|
+
"root_"."locale" IN (?) as "root_$predicate_localePredicate",
|
|
68
68
|
"root_"."title" AS "root_title"
|
|
69
69
|
FROM "public"."post_locale" AS "root_"`,
|
|
70
70
|
parameters: ['cs'],
|
|
@@ -73,12 +73,12 @@ test('querying id and title', async () => {
|
|
|
73
73
|
{
|
|
74
74
|
root_id: testUuid(1),
|
|
75
75
|
root_title: null,
|
|
76
|
-
|
|
76
|
+
'root_$predicate_localePredicate': false,
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
79
|
root_id: testUuid(2),
|
|
80
80
|
root_title: 'bar',
|
|
81
|
-
|
|
81
|
+
'root_$predicate_localePredicate': true,
|
|
82
82
|
},
|
|
83
83
|
],
|
|
84
84
|
},
|
|
@@ -131,7 +131,7 @@ test('querying with extra where', async () => {
|
|
|
131
131
|
{
|
|
132
132
|
sql: SQL`select
|
|
133
133
|
"root_"."id" as "root_id",
|
|
134
|
-
"root_"."locale" in (?) as "
|
|
134
|
+
"root_"."locale" in (?) as "root_$predicate_localePredicate",
|
|
135
135
|
"root_"."title" as "root_title"
|
|
136
136
|
from "public"."post_locale" as "root_"
|
|
137
137
|
where "root_"."title" = ? and "root_"."locale" in (?)`,
|
|
@@ -141,7 +141,7 @@ test('querying with extra where', async () => {
|
|
|
141
141
|
{
|
|
142
142
|
root_id: testUuid(1),
|
|
143
143
|
root_title: 'foo',
|
|
144
|
-
|
|
144
|
+
'root_$predicate_localePredicate': true,
|
|
145
145
|
},
|
|
146
146
|
],
|
|
147
147
|
},
|
|
@@ -216,7 +216,7 @@ test('not defined acl variable', async () => {
|
|
|
216
216
|
{
|
|
217
217
|
sql: SQL`
|
|
218
218
|
select "root_"."id" as "root_id",
|
|
219
|
-
false as "
|
|
219
|
+
false as "root_$predicate_localePredicate",
|
|
220
220
|
"root_"."title" as "root_title"
|
|
221
221
|
from "public"."post_locale" as "root_"`,
|
|
222
222
|
parameters: [],
|
|
@@ -252,7 +252,7 @@ test('querying on nested field', async () => {
|
|
|
252
252
|
executes: [
|
|
253
253
|
{
|
|
254
254
|
sql: SQL`select
|
|
255
|
-
"root_"."id" as "
|
|
255
|
+
"root_"."id" as "root_$key_id",
|
|
256
256
|
"root_"."id" as "root_id"
|
|
257
257
|
from "public"."post" as "root_"`,
|
|
258
258
|
parameters: [],
|
|
@@ -260,9 +260,11 @@ test('querying on nested field', async () => {
|
|
|
260
260
|
rows: [
|
|
261
261
|
{
|
|
262
262
|
root_id: testUuid(1),
|
|
263
|
+
'root_$key_id': testUuid(1),
|
|
263
264
|
},
|
|
264
265
|
{
|
|
265
266
|
root_id: testUuid(2),
|
|
267
|
+
'root_$key_id': testUuid(2),
|
|
266
268
|
},
|
|
267
269
|
],
|
|
268
270
|
},
|
|
@@ -271,7 +273,7 @@ test('querying on nested field', async () => {
|
|
|
271
273
|
sql: SQL`
|
|
272
274
|
select "root_"."post_id" as "__grouping_key",
|
|
273
275
|
"root_"."id" as "root_id",
|
|
274
|
-
"root_"."locale" in (?) as "
|
|
276
|
+
"root_"."locale" in (?) as "root_$predicate_localePredicate",
|
|
275
277
|
"root_"."title" as "root_title"
|
|
276
278
|
from "public"."post_locale" as "root_" where "root_"."post_id" in (?, ?)`,
|
|
277
279
|
parameters: ['cs', testUuid(1), testUuid(2)],
|
|
@@ -280,13 +282,13 @@ test('querying on nested field', async () => {
|
|
|
280
282
|
{
|
|
281
283
|
__grouping_key: testUuid(1),
|
|
282
284
|
root_id: testUuid(3),
|
|
283
|
-
|
|
285
|
+
'root_$predicate_localePredicate': false,
|
|
284
286
|
root_title: 'foo',
|
|
285
287
|
},
|
|
286
288
|
{
|
|
287
289
|
__grouping_key: testUuid(2),
|
|
288
290
|
root_id: testUuid(4),
|
|
289
|
-
|
|
291
|
+
'root_$predicate_localePredicate': true,
|
|
290
292
|
root_title: 'bar',
|
|
291
293
|
},
|
|
292
294
|
],
|
package/tests/cases/integration/graphQlRequests/query/acl/metaReadableThroughContext.test.ts
CHANGED
|
@@ -91,12 +91,12 @@ test('_meta.readable and _meta.updatable follow the nested permission set throug
|
|
|
91
91
|
}`,
|
|
92
92
|
executes: [
|
|
93
93
|
{
|
|
94
|
-
sql: SQL`select "root_"."id" as "
|
|
94
|
+
sql: SQL`select "root_"."id" as "root_$key_id", "root_"."id" as "root_id" from "public"."post" as "root_"`,
|
|
95
95
|
parameters: [],
|
|
96
96
|
response: {
|
|
97
97
|
rows: [
|
|
98
|
-
{ root_id: testUuid(1) },
|
|
99
|
-
{ root_id: testUuid(2) },
|
|
98
|
+
{ root_id: testUuid(1), 'root_$key_id': testUuid(1) },
|
|
99
|
+
{ root_id: testUuid(2), 'root_$key_id': testUuid(2) },
|
|
100
100
|
],
|
|
101
101
|
},
|
|
102
102
|
},
|
|
@@ -196,12 +196,12 @@ test('_meta.readable compiles a through-only cell predicate against the nested p
|
|
|
196
196
|
`,
|
|
197
197
|
executes: [
|
|
198
198
|
{
|
|
199
|
-
sql: SQL`select "root_"."id" as "
|
|
199
|
+
sql: SQL`select "root_"."id" as "root_$key_id", "root_"."id" as "root_id" from "public"."post" as "root_"`,
|
|
200
200
|
parameters: [],
|
|
201
201
|
response: {
|
|
202
202
|
rows: [
|
|
203
|
-
{ root_id: testUuid(1) },
|
|
204
|
-
{ root_id: testUuid(2) },
|
|
203
|
+
{ root_id: testUuid(1), 'root_$key_id': testUuid(1) },
|
|
204
|
+
{ root_id: testUuid(2), 'root_$key_id': testUuid(2) },
|
|
205
205
|
],
|
|
206
206
|
},
|
|
207
207
|
},
|
|
@@ -209,14 +209,14 @@ test('_meta.readable compiles a through-only cell predicate against the nested p
|
|
|
209
209
|
sql: SQL`
|
|
210
210
|
select "root_"."post_id" as "__grouping_key",
|
|
211
211
|
"root_"."id" as "root_id",
|
|
212
|
-
"root_"."visible" = ? as "
|
|
212
|
+
"root_"."visible" = ? as "root_$predicate_titleVisible"
|
|
213
213
|
from "public"."post_locale" as "root_" where "root_"."post_id" in (?, ?)
|
|
214
214
|
`,
|
|
215
215
|
parameters: [true, testUuid(1), testUuid(2)],
|
|
216
216
|
response: {
|
|
217
217
|
rows: [
|
|
218
|
-
{ __grouping_key: testUuid(1), root_id: testUuid(3),
|
|
219
|
-
{ __grouping_key: testUuid(2), root_id: testUuid(4),
|
|
218
|
+
{ __grouping_key: testUuid(1), root_id: testUuid(3), 'root_$predicate_titleVisible': true },
|
|
219
|
+
{ __grouping_key: testUuid(2), root_id: testUuid(4), 'root_$predicate_titleVisible': false },
|
|
220
220
|
],
|
|
221
221
|
},
|
|
222
222
|
},
|
|
@@ -277,12 +277,12 @@ test('nested _meta.updatable resolves its predicate against the nested permissio
|
|
|
277
277
|
`,
|
|
278
278
|
executes: [
|
|
279
279
|
{
|
|
280
|
-
sql: SQL`select "root_"."id" as "
|
|
280
|
+
sql: SQL`select "root_"."id" as "root_$key_id", "root_"."id" as "root_id" from "public"."post" as "root_"`,
|
|
281
281
|
parameters: [],
|
|
282
282
|
response: {
|
|
283
283
|
rows: [
|
|
284
|
-
{ root_id: testUuid(1) },
|
|
285
|
-
{ root_id: testUuid(2) },
|
|
284
|
+
{ root_id: testUuid(1), 'root_$key_id': testUuid(1) },
|
|
285
|
+
{ root_id: testUuid(2), 'root_$key_id': testUuid(2) },
|
|
286
286
|
],
|
|
287
287
|
},
|
|
288
288
|
},
|
|
@@ -291,14 +291,14 @@ test('nested _meta.updatable resolves its predicate against the nested permissio
|
|
|
291
291
|
sql: SQL`
|
|
292
292
|
select "root_"."post_id" as "__grouping_key",
|
|
293
293
|
"root_"."id" as "root_id",
|
|
294
|
-
"root_"."visible" = ? as "
|
|
294
|
+
"root_"."visible" = ? as "root_$predicate_throughUpdatable"
|
|
295
295
|
from "public"."post_locale" as "root_" where "root_"."post_id" in (?, ?)
|
|
296
296
|
`,
|
|
297
297
|
parameters: [false, testUuid(1), testUuid(2)],
|
|
298
298
|
response: {
|
|
299
299
|
rows: [
|
|
300
|
-
{ __grouping_key: testUuid(1), root_id: testUuid(3),
|
|
301
|
-
{ __grouping_key: testUuid(2), root_id: testUuid(4),
|
|
300
|
+
{ __grouping_key: testUuid(1), root_id: testUuid(3), 'root_$predicate_throughUpdatable': true },
|
|
301
|
+
{ __grouping_key: testUuid(2), root_id: testUuid(4), 'root_$predicate_throughUpdatable': false },
|
|
302
302
|
],
|
|
303
303
|
},
|
|
304
304
|
},
|