@contember/engine-content-api 1.1.0-beta.1 → 1.1.0-beta.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contember/engine-content-api",
3
- "version": "1.1.0-beta.1",
3
+ "version": "1.1.0-beta.4",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/src/index.js",
6
6
  "typings": "dist/src/index.d.ts",
@@ -10,19 +10,19 @@
10
10
  "test": "vitest --no-threads"
11
11
  },
12
12
  "dependencies": {
13
- "@contember/database": "^1.1.0-beta.1",
14
- "@contember/dic": "^1.1.0-beta.1",
15
- "@contember/engine-common": "^1.1.0-beta.1",
16
- "@contember/graphql-utils": "^1.1.0-beta.1",
17
- "@contember/schema": "^1.1.0-beta.1",
18
- "@contember/schema-utils": "^1.1.0-beta.1",
13
+ "@contember/database": "^1.1.0-beta.4",
14
+ "@contember/dic": "^1.1.0-beta.4",
15
+ "@contember/engine-common": "^1.1.0-beta.4",
16
+ "@contember/graphql-utils": "^1.1.0-beta.4",
17
+ "@contember/schema": "^1.1.0-beta.4",
18
+ "@contember/schema-utils": "^1.1.0-beta.4",
19
19
  "@graphql-tools/schema": "^8.3.5",
20
20
  "graphql-tag": "^2.12.5"
21
21
  },
22
22
  "devDependencies": {
23
- "@contember/database-tester": "^1.1.0-beta.1",
24
- "@contember/engine-api-tester": "^1.1.0-beta.1",
25
- "@contember/schema-definition": "^1.1.0-beta.1",
23
+ "@contember/database-tester": "^1.1.0-beta.4",
24
+ "@contember/engine-api-tester": "^1.1.0-beta.4",
25
+ "@contember/schema-definition": "^1.1.0-beta.4",
26
26
  "@graphql-codegen/cli": "^1.15.2",
27
27
  "@graphql-codegen/typescript": "^1.15.2",
28
28
  "@graphql-codegen/typescript-operations": "^1.15.2",
@@ -70,7 +70,7 @@ export class JoinVisitor implements Model.RelationByTypeVisitor<JoinDefinition[]
70
70
  ): JoinDefinition[] {
71
71
  const sourceAlias = this.path.back().alias
72
72
  const targetAlias = this.path.alias
73
- const joiningAlias = `${sourceAlias}_x_${targetAlias}`
73
+ const joiningAlias = this.path.back().for('x_' + this.path.alias).alias
74
74
  return [
75
75
  {
76
76
  tableName: relation.joiningTable.tableName,
@@ -98,7 +98,7 @@ export class JoinVisitor implements Model.RelationByTypeVisitor<JoinDefinition[]
98
98
  ): JoinDefinition[] {
99
99
  const sourceAlias = this.path.back().alias
100
100
  const targetAlias = this.path.alias
101
- const joiningAlias = `${sourceAlias}_x_${targetAlias}`
101
+ const joiningAlias = this.path.back().for('x_' + this.path.alias).alias
102
102
  return [
103
103
  {
104
104
  tableName: targetRelation.joiningTable.tableName,
@@ -2,7 +2,7 @@ import { GraphQLScalarType, Kind } from 'graphql'
2
2
  import { JSONType } from '@contember/graphql-utils'
3
3
 
4
4
 
5
- const uuidPattern = /^[0-9a-f]{8}-?[0-9a-f]{4}-?[1-5][0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$/i
5
+ const uuidPattern = /^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$/i
6
6
  /** dashes are optional */
7
7
  const isUuid = (value: string): boolean => {
8
8
  return (
@@ -105,3 +105,62 @@ test('Post by category ids (where many has many owning)', async () => {
105
105
  })
106
106
  })
107
107
 
108
+
109
+ test('Post by category tag name (where multiple many has many owning)', async () => {
110
+ await execute({
111
+ schema: new SchemaBuilder()
112
+ .entity('Post', entity =>
113
+ entity.manyHasMany('categories', relation =>
114
+ relation.target('Category', e =>
115
+ e.manyHasMany('tagsButWithVeryVeryVeryLongNameSoItReachesPostgresqlAliasLengthLimit', relation =>
116
+ relation.target('Tag', e =>
117
+ e.column('name', c => c.type(Model.ColumnType.String)),
118
+ ),
119
+ ),
120
+ ),
121
+ ),
122
+ )
123
+ .buildSchema(),
124
+ query: GQL`
125
+ query {
126
+ listPost(filter: {categories: {tagsButWithVeryVeryVeryLongNameSoItReachesPostgresqlAliasLengthLimit: {name: {eq: "Stuff"}}}}) {
127
+ id
128
+ }
129
+ }`,
130
+ executes: [
131
+ {
132
+ sql: SQL`
133
+ select "root_"."id" as "root_id" from "public"."post" as "root_"
134
+ where exists (select 1
135
+ from "public"."post_categories" as "junction_"
136
+ inner join "public"."category" as "sub_" on "junction_"."category_id" = "sub_"."id"
137
+ left join "public"."category_tags_but_with_very_very_very_long_name_so_it_reaches_postgresql_alias_length_limit" as "sub_x_sub_tagsButWithVeryVeryVeryLongNameSoItReachesPostgresq_2" on "sub_"."id" = "sub_x_sub_tagsButWithVeryVeryVeryLongNameSoItReachesPostgresq_2"."category_id"
138
+ left join "public"."tag" as "sub_tagsButWithVeryVeryVeryLongNameSoItReachesPostgresqlAlias_1" on "sub_x_sub_tagsButWithVeryVeryVeryLongNameSoItReachesPostgresq_2"."tag_id" = "sub_tagsButWithVeryVeryVeryLongNameSoItReachesPostgresqlAlias_1"."id"
139
+ where "root_"."id" = "junction_"."post_id" and "sub_tagsButWithVeryVeryVeryLongNameSoItReachesPostgresqlAlias_1"."name" = ?)`,
140
+ parameters: ['Stuff'],
141
+ response: {
142
+ rows: [
143
+ {
144
+ root_id: testUuid(1),
145
+ },
146
+ {
147
+ root_id: testUuid(3),
148
+ },
149
+ ],
150
+ },
151
+ },
152
+ ],
153
+ return: {
154
+ data: {
155
+ listPost: [
156
+ {
157
+ id: testUuid(1),
158
+ },
159
+ {
160
+ id: testUuid(3),
161
+ },
162
+ ],
163
+ },
164
+ },
165
+ })
166
+ })