@contember/client-content 2.0.0-alpha.9 → 2.0.0-beta.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/development/src/ContentClient.cjs.map +1 -1
- package/dist/development/src/ContentClient.js.map +1 -1
- package/dist/development/src/ContentQueryBuilder.cjs.map +1 -1
- package/dist/development/src/ContentQueryBuilder.js.map +1 -1
- package/dist/development/src/nodes/ContentEntitySelection.cjs.map +1 -1
- package/dist/development/src/nodes/ContentEntitySelection.js.map +1 -1
- package/dist/development/src/nodes/ContentOperation.cjs.map +1 -1
- package/dist/development/src/nodes/ContentOperation.js.map +1 -1
- package/dist/development/src/utils/ContentOperationSet.cjs.map +1 -1
- package/dist/development/src/utils/ContentOperationSet.js.map +1 -1
- package/dist/development/src/utils/createListArgs.cjs.map +1 -1
- package/dist/development/src/utils/createListArgs.js.map +1 -1
- package/dist/development/src/utils/createMutationOperationSet.cjs.map +1 -1
- package/dist/development/src/utils/createMutationOperationSet.js.map +1 -1
- package/dist/development/src/utils/createQueryOperationSet.cjs.map +1 -1
- package/dist/development/src/utils/createQueryOperationSet.js.map +1 -1
- package/dist/development/src/utils/createTypedArgs.cjs.map +1 -1
- package/dist/development/src/utils/createTypedArgs.js.map +1 -1
- package/dist/development/src/utils/mutationFragments.cjs.map +1 -1
- package/dist/development/src/utils/mutationFragments.js.map +1 -1
- package/dist/production/src/ContentClient.cjs.map +1 -1
- package/dist/production/src/ContentClient.js.map +1 -1
- package/dist/production/src/ContentQueryBuilder.cjs.map +1 -1
- package/dist/production/src/ContentQueryBuilder.js.map +1 -1
- package/dist/production/src/nodes/ContentEntitySelection.cjs.map +1 -1
- package/dist/production/src/nodes/ContentEntitySelection.js.map +1 -1
- package/dist/production/src/nodes/ContentOperation.cjs.map +1 -1
- package/dist/production/src/nodes/ContentOperation.js.map +1 -1
- package/dist/production/src/utils/ContentOperationSet.cjs.map +1 -1
- package/dist/production/src/utils/ContentOperationSet.js.map +1 -1
- package/dist/production/src/utils/createListArgs.cjs.map +1 -1
- package/dist/production/src/utils/createListArgs.js.map +1 -1
- package/dist/production/src/utils/createMutationOperationSet.cjs.map +1 -1
- package/dist/production/src/utils/createMutationOperationSet.js.map +1 -1
- package/dist/production/src/utils/createQueryOperationSet.cjs.map +1 -1
- package/dist/production/src/utils/createQueryOperationSet.js.map +1 -1
- package/dist/production/src/utils/createTypedArgs.cjs.map +1 -1
- package/dist/production/src/utils/createTypedArgs.js.map +1 -1
- package/dist/production/src/utils/mutationFragments.cjs.map +1 -1
- package/dist/production/src/utils/mutationFragments.js.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/types/Schema.d.ts +6 -3
- package/dist/types/types/Schema.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/types/Schema.ts +6 -3
- package/tests/cases/unit/__snapshots__/mutation.test.ts.snap +1198 -0
- package/tests/cases/unit/__snapshots__/query.test.ts.snap +102 -0
- package/tests/cases/unit/mutation.test.ts +244 -1199
- package/tests/cases/unit/query.test.ts +55 -124
- package/tests/cases/unit/types.test.ts +3 -2
- package/tests/client/enums.ts +3 -1
- package/tests/client/names.ts +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, expect, test } from '
|
|
1
|
+
import { describe, expect, test } from 'bun:test'
|
|
2
2
|
import { createClient } from '../../lib'
|
|
3
3
|
import { Input } from '@contember/schema'
|
|
4
4
|
import OrderDirection = Input.OrderDirection
|
|
@@ -11,10 +11,12 @@ describe('queries', () => {
|
|
|
11
11
|
const [client, calls] = createClient({
|
|
12
12
|
authors: [
|
|
13
13
|
{
|
|
14
|
+
id: '1',
|
|
14
15
|
name: 'John',
|
|
15
16
|
email: 'foo@localhost',
|
|
16
17
|
},
|
|
17
18
|
{
|
|
19
|
+
id: '2',
|
|
18
20
|
name: 'John',
|
|
19
21
|
email: 'bar@localhost',
|
|
20
22
|
},
|
|
@@ -23,30 +25,23 @@ describe('queries', () => {
|
|
|
23
25
|
const result = await client.query({
|
|
24
26
|
authors: qb.list('Author', {}, it => it.$$()),
|
|
25
27
|
})
|
|
26
|
-
expect(result).
|
|
28
|
+
expect(result).toStrictEqual({
|
|
27
29
|
authors: [
|
|
28
30
|
{
|
|
31
|
+
id: '1',
|
|
29
32
|
name: 'John',
|
|
30
33
|
email: 'foo@localhost',
|
|
31
34
|
},
|
|
32
35
|
{
|
|
36
|
+
id: '2',
|
|
33
37
|
name: 'John',
|
|
34
38
|
email: 'bar@localhost',
|
|
35
39
|
},
|
|
36
40
|
],
|
|
37
41
|
})
|
|
38
42
|
expect(calls).toHaveLength(1)
|
|
39
|
-
expect(calls[0].query).
|
|
40
|
-
|
|
41
|
-
authors: listAuthor {
|
|
42
|
-
id
|
|
43
|
-
name
|
|
44
|
-
email
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
"
|
|
48
|
-
`)
|
|
49
|
-
expect(calls[0].variables).toMatchInlineSnapshot('{}')
|
|
43
|
+
expect(calls[0].query).toMatchSnapshot()
|
|
44
|
+
expect(calls[0].variables).toStrictEqual({})
|
|
50
45
|
})
|
|
51
46
|
|
|
52
47
|
test('multiple queries', async () => {
|
|
@@ -76,7 +71,7 @@ describe('queries', () => {
|
|
|
76
71
|
authors: qb.list('Author', {}, it => it.$$()),
|
|
77
72
|
posts: qb.list('Post', {}, it => it.$$()),
|
|
78
73
|
})
|
|
79
|
-
expect(result).
|
|
74
|
+
expect(result as any).toStrictEqual({
|
|
80
75
|
authors: [
|
|
81
76
|
{
|
|
82
77
|
name: 'John',
|
|
@@ -99,21 +94,8 @@ describe('queries', () => {
|
|
|
99
94
|
],
|
|
100
95
|
})
|
|
101
96
|
expect(calls).toHaveLength(1)
|
|
102
|
-
expect(calls[0].query).
|
|
103
|
-
|
|
104
|
-
authors: listAuthor {
|
|
105
|
-
id
|
|
106
|
-
name
|
|
107
|
-
email
|
|
108
|
-
}
|
|
109
|
-
posts: listPost {
|
|
110
|
-
id
|
|
111
|
-
publishedAt
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
"
|
|
115
|
-
`)
|
|
116
|
-
expect(calls[0].variables).toMatchInlineSnapshot('{}')
|
|
97
|
+
expect(calls[0].query).toMatchSnapshot()
|
|
98
|
+
expect(calls[0].variables).toEqual({})
|
|
117
99
|
})
|
|
118
100
|
|
|
119
101
|
|
|
@@ -132,7 +114,7 @@ describe('queries', () => {
|
|
|
132
114
|
})
|
|
133
115
|
|
|
134
116
|
const result = await client.query(qb.list('Post', {}, it => it.$$()))
|
|
135
|
-
expect(result).
|
|
117
|
+
expect(result as any).toStrictEqual([
|
|
136
118
|
{
|
|
137
119
|
title: 'Post 1',
|
|
138
120
|
content: 'Content 1',
|
|
@@ -143,16 +125,8 @@ describe('queries', () => {
|
|
|
143
125
|
},
|
|
144
126
|
])
|
|
145
127
|
expect(calls).toHaveLength(1)
|
|
146
|
-
expect(calls[0].query).
|
|
147
|
-
|
|
148
|
-
value: listPost {
|
|
149
|
-
id
|
|
150
|
-
publishedAt
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
"
|
|
154
|
-
`)
|
|
155
|
-
expect(calls[0].variables).toMatchInlineSnapshot('{}')
|
|
128
|
+
expect(calls[0].query).toMatchSnapshot()
|
|
129
|
+
expect(calls[0].variables).toEqual({})
|
|
156
130
|
})
|
|
157
131
|
|
|
158
132
|
|
|
@@ -162,25 +136,8 @@ describe('queries', () => {
|
|
|
162
136
|
authors: qb.list('Author', {}, it => it.$$().$('posts', {}, it => it.$$().$('tags', {}, it => it.$$()))),
|
|
163
137
|
})
|
|
164
138
|
expect(calls).toHaveLength(1)
|
|
165
|
-
expect(calls[0].query).
|
|
166
|
-
|
|
167
|
-
authors: listAuthor {
|
|
168
|
-
id
|
|
169
|
-
name
|
|
170
|
-
email
|
|
171
|
-
posts {
|
|
172
|
-
id
|
|
173
|
-
publishedAt
|
|
174
|
-
tags {
|
|
175
|
-
id
|
|
176
|
-
name
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
"
|
|
182
|
-
`)
|
|
183
|
-
expect(calls[0].variables).toMatchInlineSnapshot('{}')
|
|
139
|
+
expect(calls[0].query).toMatchSnapshot()
|
|
140
|
+
expect(calls[0].variables).toEqual({})
|
|
184
141
|
})
|
|
185
142
|
test('nested object args', async () => {
|
|
186
143
|
const [client, calls] = createClient()
|
|
@@ -191,32 +148,17 @@ describe('queries', () => {
|
|
|
191
148
|
}, it => it.$$())),
|
|
192
149
|
})
|
|
193
150
|
expect(calls).toHaveLength(1)
|
|
194
|
-
expect(calls[0].query).
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
"
|
|
207
|
-
`)
|
|
208
|
-
expect(calls[0].variables).toMatchInlineSnapshot(`
|
|
209
|
-
{
|
|
210
|
-
"Int_1": 10,
|
|
211
|
-
"PostWhere_0": {
|
|
212
|
-
"tags": {
|
|
213
|
-
"name": {
|
|
214
|
-
"eq": "foo",
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
}
|
|
219
|
-
`)
|
|
151
|
+
expect(calls[0].query).toMatchSnapshot()
|
|
152
|
+
expect(calls[0].variables).toStrictEqual({
|
|
153
|
+
'Int_1': 10,
|
|
154
|
+
'PostWhere_0': {
|
|
155
|
+
'tags': {
|
|
156
|
+
'name': {
|
|
157
|
+
'eq': 'foo',
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
})
|
|
220
162
|
})
|
|
221
163
|
|
|
222
164
|
|
|
@@ -231,7 +173,7 @@ describe('queries', () => {
|
|
|
231
173
|
}, it => it.$$()),
|
|
232
174
|
})
|
|
233
175
|
expect(calls).toHaveLength(1)
|
|
234
|
-
expect(calls[0].query).
|
|
176
|
+
expect(calls[0].query).toMatchSnapshot(`
|
|
235
177
|
"query($AuthorWhere_0: AuthorWhere, $AuthorOrderBy_1: [AuthorOrderBy!], $Int_2: Int, $Int_3: Int) {
|
|
236
178
|
authors: listAuthor(filter: $AuthorWhere_0, orderBy: $AuthorOrderBy_1, limit: $Int_2, offset: $Int_3) {
|
|
237
179
|
id
|
|
@@ -241,22 +183,22 @@ describe('queries', () => {
|
|
|
241
183
|
}
|
|
242
184
|
"
|
|
243
185
|
`)
|
|
244
|
-
expect(calls[0].variables).
|
|
186
|
+
expect(calls[0].variables).toStrictEqual(
|
|
245
187
|
{
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
|
|
188
|
+
'AuthorOrderBy_1': [
|
|
189
|
+
{
|
|
190
|
+
'name': 'asc',
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
'AuthorWhere_0': {
|
|
194
|
+
'name': {
|
|
195
|
+
'eq': 'John',
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
'Int_2': 10,
|
|
199
|
+
'Int_3': 20,
|
|
200
|
+
},
|
|
201
|
+
)
|
|
260
202
|
})
|
|
261
203
|
|
|
262
204
|
|
|
@@ -268,23 +210,12 @@ describe('queries', () => {
|
|
|
268
210
|
}, it => it.$$()),
|
|
269
211
|
})
|
|
270
212
|
expect(calls).toHaveLength(1)
|
|
271
|
-
expect(calls[0].query).
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
"
|
|
280
|
-
`)
|
|
281
|
-
expect(calls[0].variables).toMatchInlineSnapshot(`
|
|
282
|
-
{
|
|
283
|
-
"AuthorUniqueWhere_0": {
|
|
284
|
-
"id": "ca7a9b84-efbb-435d-a063-da11f205335a",
|
|
285
|
-
},
|
|
286
|
-
}
|
|
287
|
-
`)
|
|
213
|
+
expect(calls[0].query).toMatchSnapshot()
|
|
214
|
+
expect(calls[0].variables).toEqual({
|
|
215
|
+
'AuthorUniqueWhere_0': {
|
|
216
|
+
'id': 'ca7a9b84-efbb-435d-a063-da11f205335a',
|
|
217
|
+
},
|
|
218
|
+
})
|
|
288
219
|
})
|
|
289
220
|
|
|
290
221
|
test('top level list transform', async () => {
|
|
@@ -309,7 +240,7 @@ describe('queries', () => {
|
|
|
309
240
|
})),
|
|
310
241
|
),
|
|
311
242
|
})
|
|
312
|
-
expect(result).
|
|
243
|
+
expect(result as any).toStrictEqual({
|
|
313
244
|
authors: [
|
|
314
245
|
{
|
|
315
246
|
name: 'John',
|
|
@@ -342,7 +273,7 @@ describe('queries', () => {
|
|
|
342
273
|
})),
|
|
343
274
|
),
|
|
344
275
|
})
|
|
345
|
-
expect(result).
|
|
276
|
+
expect(result as any).toStrictEqual({
|
|
346
277
|
author: {
|
|
347
278
|
name: 'John',
|
|
348
279
|
email: 'foo@localhost',
|
|
@@ -377,7 +308,7 @@ describe('queries', () => {
|
|
|
377
308
|
}))),
|
|
378
309
|
),
|
|
379
310
|
})
|
|
380
|
-
expect(result).
|
|
311
|
+
expect(result as any).toStrictEqual({
|
|
381
312
|
author: {
|
|
382
313
|
name: 'John',
|
|
383
314
|
email: 'foo@localhost',
|
|
@@ -421,7 +352,7 @@ describe('queries', () => {
|
|
|
421
352
|
.$('author', author),
|
|
422
353
|
),
|
|
423
354
|
})
|
|
424
|
-
expect(result).
|
|
355
|
+
expect(result as any).toStrictEqual({
|
|
425
356
|
post: {
|
|
426
357
|
publishedAt: '2021-01-01T00:00:00Z',
|
|
427
358
|
author: {
|
|
@@ -452,7 +383,7 @@ describe('queries', () => {
|
|
|
452
383
|
}))),
|
|
453
384
|
),
|
|
454
385
|
})
|
|
455
|
-
expect(result).
|
|
386
|
+
expect(result as any).toStrictEqual({
|
|
456
387
|
post: {
|
|
457
388
|
publishedAt: '2021-01-01T00:00:00Z',
|
|
458
389
|
localesByLocale: {
|
|
@@ -495,7 +426,7 @@ describe('queries', () => {
|
|
|
495
426
|
})),
|
|
496
427
|
),
|
|
497
428
|
})
|
|
498
|
-
expect(result).
|
|
429
|
+
expect(result as any).toStrictEqual({
|
|
499
430
|
author: {
|
|
500
431
|
name: 'John',
|
|
501
432
|
email: 'foo@localhost',
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
-
import {
|
|
2
|
+
import { describe, expect, test } from 'bun:test'
|
|
3
3
|
import { ContentClientInput } from '../../../src'
|
|
4
4
|
import { ContemberClientEntities, FragmentOf, FragmentType, queryBuilder } from '../../client'
|
|
5
|
+
import { expectTypeOf } from 'expect-type'
|
|
5
6
|
|
|
6
7
|
const qb = queryBuilder
|
|
7
8
|
describe('ts types', () => {
|
|
@@ -16,7 +17,7 @@ describe('ts types', () => {
|
|
|
16
17
|
const postFragment = qb.fragment('Post')
|
|
17
18
|
|
|
18
19
|
// @ts-expect-error
|
|
19
|
-
|
|
20
|
+
postFragment.$('author', qb.fragment('Post'))
|
|
20
21
|
})
|
|
21
22
|
|
|
22
23
|
test('where - valid', async () => {
|
package/tests/client/enums.ts
CHANGED