@contember/engine-content-api 1.1.0-alpha.6 → 1.1.0-alpha.7
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/dist/src/resolvers/MutationResolver.d.ts.map +1 -1
- package/dist/src/resolvers/MutationResolver.js +4 -3
- package/dist/src/resolvers/MutationResolver.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/tests/cases/integration/graphQlRequests/upsert/basicUpsert.test.js +45 -2
- package/dist/tests/cases/integration/graphQlRequests/upsert/basicUpsert.test.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/resolvers/MutationResolver.ts +4 -3
- package/tests/cases/integration/graphQlRequests/upsert/basicUpsert.test.ts +49 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/engine-content-api",
|
|
3
|
-
"version": "1.1.0-alpha.
|
|
3
|
+
"version": "1.1.0-alpha.7",
|
|
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-alpha.
|
|
14
|
-
"@contember/dic": "^1.1.0-alpha.
|
|
15
|
-
"@contember/engine-common": "^1.1.0-alpha.
|
|
16
|
-
"@contember/graphql-utils": "^1.1.0-alpha.
|
|
17
|
-
"@contember/schema": "^1.1.0-alpha.
|
|
18
|
-
"@contember/schema-utils": "^1.1.0-alpha.
|
|
13
|
+
"@contember/database": "^1.1.0-alpha.7",
|
|
14
|
+
"@contember/dic": "^1.1.0-alpha.7",
|
|
15
|
+
"@contember/engine-common": "^1.1.0-alpha.7",
|
|
16
|
+
"@contember/graphql-utils": "^1.1.0-alpha.7",
|
|
17
|
+
"@contember/schema": "^1.1.0-alpha.7",
|
|
18
|
+
"@contember/schema-utils": "^1.1.0-alpha.7",
|
|
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-alpha.
|
|
24
|
-
"@contember/engine-api-tester": "^1.1.0-alpha.
|
|
25
|
-
"@contember/schema-definition": "^1.1.0-alpha.
|
|
23
|
+
"@contember/database-tester": "^1.1.0-alpha.7",
|
|
24
|
+
"@contember/engine-api-tester": "^1.1.0-alpha.7",
|
|
25
|
+
"@contember/schema-definition": "^1.1.0-alpha.7",
|
|
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",
|
|
@@ -388,12 +388,13 @@ export class MutationResolver {
|
|
|
388
388
|
if (errorResponse) {
|
|
389
389
|
return errorResponse
|
|
390
390
|
}
|
|
391
|
-
const primary = getInsertPrimary(result)
|
|
392
|
-
|
|
391
|
+
const primary = getInsertPrimary(result)
|
|
392
|
+
const byResolved = primary ? { [entity.primary]: primary } : input.by
|
|
393
|
+
if (!byResolved) {
|
|
393
394
|
throw new ImplementationException('MutationResolver::resolveUpsertInternal does not handle result properly')
|
|
394
395
|
}
|
|
395
396
|
|
|
396
|
-
const nodes = await this.resolveResultNodes(mapper, entity,
|
|
397
|
+
const nodes = await this.resolveResultNodes(mapper, entity, byResolved, queryAst)
|
|
397
398
|
return {
|
|
398
399
|
ok: true,
|
|
399
400
|
validation: {
|
|
@@ -98,8 +98,54 @@ test('upsert author (exists)', async () => {
|
|
|
98
98
|
response: { rowCount: 1 },
|
|
99
99
|
},
|
|
100
100
|
{
|
|
101
|
-
sql: SQL`select "root_"."id" as "root_id" from "public"."author" as "root_" where "root_"."
|
|
102
|
-
parameters: [
|
|
101
|
+
sql: SQL`select "root_"."id" as "root_id" from "public"."author" as "root_" where "root_"."slug" = ?`,
|
|
102
|
+
parameters: ['john-doe'],
|
|
103
|
+
response: { rows: [{ root_id: testUuid(2) }] },
|
|
104
|
+
},
|
|
105
|
+
]),
|
|
106
|
+
],
|
|
107
|
+
return: {
|
|
108
|
+
data: {
|
|
109
|
+
upsertAuthor: {
|
|
110
|
+
ok: true,
|
|
111
|
+
node: {
|
|
112
|
+
id: testUuid(2),
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
test('upsert author (exists) with noop update)', async () => {
|
|
121
|
+
await execute({
|
|
122
|
+
schema: new SchemaBuilder()
|
|
123
|
+
.entity('Author', entity =>
|
|
124
|
+
entity
|
|
125
|
+
.column('name', c => c.type(Model.ColumnType.String))
|
|
126
|
+
.column('slug', c => c.type(Model.ColumnType.String).unique()),
|
|
127
|
+
)
|
|
128
|
+
.buildSchema(),
|
|
129
|
+
query: GQL`
|
|
130
|
+
mutation {
|
|
131
|
+
upsertAuthor(by: {slug: "john-doe"}, update: {}, create: {slug: "john-doe", name: "John Doe"}) {
|
|
132
|
+
ok
|
|
133
|
+
node {
|
|
134
|
+
id
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}`,
|
|
138
|
+
executes: [
|
|
139
|
+
...sqlTransaction([
|
|
140
|
+
{
|
|
141
|
+
sql: SQL`select "root_"."id"
|
|
142
|
+
from "public"."author" as "root_" where "root_"."slug" = ?`,
|
|
143
|
+
parameters: ['john-doe'],
|
|
144
|
+
response: { rows: [{ id: testUuid(2) }] },
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
sql: SQL`select "root_"."id" as "root_id" from "public"."author" as "root_" where "root_"."slug" = ?`,
|
|
148
|
+
parameters: ['john-doe'],
|
|
103
149
|
response: { rows: [{ root_id: testUuid(2) }] },
|
|
104
150
|
},
|
|
105
151
|
]),
|
|
@@ -117,3 +163,4 @@ test('upsert author (exists)', async () => {
|
|
|
117
163
|
})
|
|
118
164
|
})
|
|
119
165
|
|
|
166
|
+
|