@contember/engine-content-api 1.1.0-rc.3 → 1.1.2
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/input-validation/EntityRulesResolver.js +3 -3
- package/dist/src/input-validation/EntityRulesResolver.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/tests/cases/integration/graphQlDb/insert/insertSequence.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlDb/insert/insertSequence.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlDb/insert/insertSequence.test.js +38 -0
- package/dist/tests/cases/integration/graphQlDb/insert/insertSequence.test.js.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/input-validation/EntityRulesResolver.ts +3 -3
- package/tests/cases/integration/graphQlDb/insert/insertSequence.test.ts +34 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/engine-content-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
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.
|
|
14
|
-
"@contember/dic": "^1.1.
|
|
15
|
-
"@contember/engine-common": "^1.1.
|
|
16
|
-
"@contember/graphql-utils": "^1.1.
|
|
17
|
-
"@contember/schema": "^1.1.
|
|
18
|
-
"@contember/schema-utils": "^1.1.
|
|
13
|
+
"@contember/database": "^1.1.2",
|
|
14
|
+
"@contember/dic": "^1.1.2",
|
|
15
|
+
"@contember/engine-common": "^1.1.2",
|
|
16
|
+
"@contember/graphql-utils": "^1.1.2",
|
|
17
|
+
"@contember/schema": "^1.1.2",
|
|
18
|
+
"@contember/schema-utils": "^1.1.2",
|
|
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.
|
|
24
|
-
"@contember/engine-api-tester": "^1.1.
|
|
25
|
-
"@contember/schema-definition": "^1.1.
|
|
23
|
+
"@contember/database-tester": "^1.1.2",
|
|
24
|
+
"@contember/engine-api-tester": "^1.1.2",
|
|
25
|
+
"@contember/schema-definition": "^1.1.2",
|
|
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",
|
|
@@ -35,7 +35,7 @@ export class EntityRulesResolver {
|
|
|
35
35
|
|
|
36
36
|
public getEntityRules(entityName: string): Validation.EntityRules {
|
|
37
37
|
const definedRules = this.validationSchema[entityName] || {}
|
|
38
|
-
const fieldsNotNullFlag = acceptEveryFieldVisitor(this.model, entityName, new
|
|
38
|
+
const fieldsNotNullFlag = acceptEveryFieldVisitor(this.model, entityName, new RequiredFieldsVisitor())
|
|
39
39
|
const notNullFields = Object.keys(filterObject(fieldsNotNullFlag, (field, val) => val))
|
|
40
40
|
return notNullFields.reduce(
|
|
41
41
|
(entityRules, field) => ({
|
|
@@ -50,9 +50,9 @@ export class EntityRulesResolver {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
class
|
|
53
|
+
class RequiredFieldsVisitor implements Model.RelationByTypeVisitor<boolean>, Model.ColumnVisitor<boolean> {
|
|
54
54
|
visitColumn(entity: Model.Entity, column: Model.AnyColumn): boolean {
|
|
55
|
-
return !column.nullable
|
|
55
|
+
return !column.nullable && typeof column.default === 'undefined' && !column.sequence
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
visitManyHasManyInverse(): boolean {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SchemaDefinition as def } from '@contember/schema-definition'
|
|
2
|
+
import { GQL } from '../../../../src/tags'
|
|
3
|
+
import { test } from 'vitest'
|
|
4
|
+
import { executeDbTest } from '@contember/engine-api-tester'
|
|
5
|
+
|
|
6
|
+
namespace SeqModel {
|
|
7
|
+
export class Order {
|
|
8
|
+
seqId = def.intColumn().sequence().notNull()
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
test('insert author with id', async () => {
|
|
13
|
+
const schema = def.createModel(SeqModel)
|
|
14
|
+
await executeDbTest({
|
|
15
|
+
schema: schema,
|
|
16
|
+
query: GQL`
|
|
17
|
+
mutation {
|
|
18
|
+
createOrder(data: {}) {
|
|
19
|
+
node {
|
|
20
|
+
seqId
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}`,
|
|
24
|
+
seed: [],
|
|
25
|
+
return: {
|
|
26
|
+
createOrder: {
|
|
27
|
+
node: {
|
|
28
|
+
seqId: 1,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|