drizzle-graphql-plus 0.8.6 → 0.8.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.
@@ -1,3749 +0,0 @@
1
- import {
2
- buildSchema,
3
- type DeleteResolver,
4
- type ExtractTables,
5
- type GeneratedEntities,
6
- type InsertArrResolver,
7
- type InsertResolver,
8
- type SelectResolver,
9
- type SelectSingleResolver,
10
- type UpdateResolver,
11
- } from '@/index';
12
- import { type Client, createClient } from '@libsql/client';
13
- import { Relations, sql } from 'drizzle-orm';
14
- import { drizzle } from 'drizzle-orm/libsql';
15
- import { type BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
16
- import {
17
- GraphQLInputObjectType,
18
- GraphQLList,
19
- GraphQLNonNull,
20
- GraphQLObjectType,
21
- GraphQLScalarType,
22
- GraphQLSchema,
23
- } from 'graphql';
24
- import { createYoga } from 'graphql-yoga';
25
- import { createServer, type Server } from 'node:http';
26
- import path from 'path';
27
- import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, expectTypeOf, it } from 'vitest';
28
- import z from 'zod';
29
- import * as schema from './schema/sqlite';
30
- import { GraphQLClient } from './util/query';
31
-
32
- interface Context {
33
- db: BaseSQLiteDatabase<'async', any, typeof schema>;
34
- client: Client;
35
- schema: GraphQLSchema;
36
- entities: GeneratedEntities<BaseSQLiteDatabase<'async', any, typeof schema>>;
37
- server: Server;
38
- gql: GraphQLClient;
39
- }
40
-
41
- const ctx: Context = {} as any;
42
-
43
- beforeAll(async () => {
44
- const sleep = 250;
45
- let timeLeft = 5000;
46
- let connected = false;
47
- let lastError: unknown | undefined;
48
-
49
- do {
50
- try {
51
- ctx.client = createClient({
52
- url: `file://${path.join(__dirname, '/.temp/db.sqlite')}`,
53
- });
54
- connected = true;
55
- break;
56
- } catch (e) {
57
- lastError = e;
58
- await new Promise((resolve) => setTimeout(resolve, sleep));
59
- timeLeft -= sleep;
60
- }
61
- } while (timeLeft > 0);
62
-
63
- if (!connected) {
64
- console.error('Cannot connect to libsql');
65
- throw lastError;
66
- }
67
-
68
- ctx.db = drizzle(ctx.client, {
69
- schema,
70
- logger: process.env['LOG_SQL'] ? true : false,
71
- });
72
-
73
- const { schema: gqlSchema, entities } = buildSchema(ctx.db);
74
- const yoga = createYoga({
75
- schema: gqlSchema,
76
- });
77
- const server = createServer(yoga);
78
-
79
- const port = 4003;
80
- server.listen(port);
81
- const gql = new GraphQLClient(`http://localhost:${port}/graphql`);
82
-
83
- ctx.schema = gqlSchema;
84
- ctx.entities = entities;
85
- ctx.server = server;
86
- ctx.gql = gql;
87
- });
88
-
89
- afterAll(async (t) => {
90
- ctx.client.close();
91
- });
92
-
93
- beforeEach(async (t) => {
94
- await ctx.db.run(sql`CREATE TABLE IF NOT EXISTS \`customers\` (
95
- \`id\` integer PRIMARY KEY NOT NULL,
96
- \`address\` text NOT NULL,
97
- \`is_confirmed\` integer,
98
- \`registration_date\` integer NOT NULL,
99
- \`user_id\` integer NOT NULL,
100
- FOREIGN KEY (\`user_id\`) REFERENCES \`users\`(\`id\`) ON UPDATE no action ON DELETE no action
101
- );`);
102
-
103
- await ctx.db.run(sql`CREATE TABLE IF NOT EXISTS \`posts\` (
104
- \`id\` integer PRIMARY KEY NOT NULL,
105
- \`content\` text,
106
- \`author_id\` integer
107
- );`);
108
-
109
- await ctx.db.run(sql`CREATE TABLE IF NOT EXISTS \`users\` (
110
- \`id\` integer PRIMARY KEY NOT NULL,
111
- \`name\` text NOT NULL,
112
- \`email\` text,
113
- \`text_json\` text,
114
- \`blob_bigint\` blob,
115
- \`numeric\` numeric,
116
- \`created_at\` integer,
117
- \`created_at_ms\` integer,
118
- \`real\` real,
119
- \`text\` text(255),
120
- \`role\` text DEFAULT 'user',
121
- \`is_confirmed\` integer
122
- );`);
123
-
124
- await ctx.db.insert(schema.Users).values([
125
- {
126
- id: 1,
127
- name: 'FirstUser',
128
- email: 'userOne@notmail.com',
129
- textJson: { field: 'value' },
130
- blobBigInt: BigInt(10),
131
- numeric: '250.2',
132
- createdAt: new Date('2024-04-02T06:44:41.785Z'),
133
- createdAtMs: new Date('2024-04-02T06:44:41.785Z'),
134
- real: 13.5,
135
- text: 'sometext',
136
- role: 'admin',
137
- isConfirmed: true,
138
- },
139
- {
140
- id: 2,
141
- name: 'SecondUser',
142
- createdAt: new Date('2024-04-02T06:44:41.785Z'),
143
- },
144
- {
145
- id: 5,
146
- name: 'FifthUser',
147
- createdAt: new Date('2024-04-02T06:44:41.785Z'),
148
- },
149
- ]);
150
-
151
- await ctx.db.insert(schema.Posts).values([
152
- {
153
- id: 1,
154
- authorId: 1,
155
- content: '1MESSAGE',
156
- },
157
- {
158
- id: 2,
159
- authorId: 1,
160
- content: '2MESSAGE',
161
- },
162
- {
163
- id: 3,
164
- authorId: 1,
165
- content: '3MESSAGE',
166
- },
167
- {
168
- id: 4,
169
- authorId: 5,
170
- content: '1MESSAGE',
171
- },
172
- {
173
- id: 5,
174
- authorId: 5,
175
- content: '2MESSAGE',
176
- },
177
- {
178
- id: 6,
179
- authorId: 1,
180
- content: '4MESSAGE',
181
- },
182
- ]);
183
-
184
- await ctx.db.insert(schema.Customers).values([
185
- {
186
- id: 1,
187
- address: 'AdOne',
188
- isConfirmed: false,
189
- registrationDate: new Date('2024-03-27T03:54:45.235Z'),
190
- userId: 1,
191
- },
192
- {
193
- id: 2,
194
- address: 'AdTwo',
195
- isConfirmed: false,
196
- registrationDate: new Date('2024-03-27T03:55:42.358Z'),
197
- userId: 2,
198
- },
199
- ]);
200
- });
201
-
202
- afterEach(async (t) => {
203
- await ctx.db.run(sql`PRAGMA foreign_keys = OFF;`);
204
- await ctx.db.run(sql`DROP TABLE IF EXISTS \`customers\`;`);
205
- await ctx.db.run(sql`DROP TABLE IF EXISTS \`posts\`;`);
206
- await ctx.db.run(sql`DROP TABLE IF EXISTS \`users\`;`);
207
- await ctx.db.run(sql`PRAGMA foreign_keys = ON;`);
208
- });
209
-
210
- describe.sequential('Query tests', async () => {
211
- it(`Select single`, async () => {
212
- const res = await ctx.gql.queryGql(/* GraphQL */ `
213
- {
214
- usersSingle {
215
- id
216
- name
217
- email
218
- textJson
219
- blobBigInt
220
- numeric
221
- createdAt
222
- createdAtMs
223
- real
224
- text
225
- role
226
- isConfirmed
227
- }
228
-
229
- postsSingle {
230
- id
231
- authorId
232
- content
233
- }
234
- }
235
- `);
236
-
237
- expect(res).toStrictEqual({
238
- data: {
239
- usersSingle: {
240
- id: 1,
241
- name: 'FirstUser',
242
- email: 'userOne@notmail.com',
243
- textJson: '{"field":"value"}',
244
- blobBigInt: '10',
245
- numeric: '250.2',
246
- createdAt: '2024-04-02T06:44:41.000Z',
247
- createdAtMs: '2024-04-02T06:44:41.785Z',
248
- real: 13.5,
249
- text: 'sometext',
250
- role: 'admin',
251
- isConfirmed: true,
252
- },
253
- postsSingle: {
254
- id: 1,
255
- authorId: 1,
256
- content: '1MESSAGE',
257
- },
258
- },
259
- });
260
- });
261
-
262
- it(`Select array`, async () => {
263
- const res = await ctx.gql.queryGql(/* GraphQL */ `
264
- {
265
- users {
266
- id
267
- name
268
- email
269
- textJson
270
- blobBigInt
271
- numeric
272
- createdAt
273
- createdAtMs
274
- real
275
- text
276
- role
277
- isConfirmed
278
- }
279
-
280
- posts {
281
- id
282
- authorId
283
- content
284
- }
285
- }
286
- `);
287
-
288
- expect(res).toStrictEqual({
289
- data: {
290
- users: [
291
- {
292
- id: 1,
293
- name: 'FirstUser',
294
- email: 'userOne@notmail.com',
295
- textJson: '{"field":"value"}',
296
- blobBigInt: '10',
297
- numeric: '250.2',
298
- createdAt: '2024-04-02T06:44:41.000Z',
299
- createdAtMs: '2024-04-02T06:44:41.785Z',
300
- real: 13.5,
301
- text: 'sometext',
302
- role: 'admin',
303
- isConfirmed: true,
304
- },
305
- {
306
- id: 2,
307
- name: 'SecondUser',
308
- email: null,
309
- blobBigInt: null,
310
- textJson: null,
311
- createdAt: '2024-04-02T06:44:41.000Z',
312
- createdAtMs: null,
313
- numeric: null,
314
- real: null,
315
- text: null,
316
- role: 'user',
317
- isConfirmed: null,
318
- },
319
- {
320
- id: 5,
321
- name: 'FifthUser',
322
- email: null,
323
- createdAt: '2024-04-02T06:44:41.000Z',
324
- role: 'user',
325
- blobBigInt: null,
326
- textJson: null,
327
- createdAtMs: null,
328
- numeric: null,
329
- real: null,
330
- text: null,
331
- isConfirmed: null,
332
- },
333
- ],
334
- posts: [
335
- {
336
- id: 1,
337
- authorId: 1,
338
- content: '1MESSAGE',
339
- },
340
- {
341
- id: 2,
342
- authorId: 1,
343
- content: '2MESSAGE',
344
- },
345
- {
346
- id: 3,
347
- authorId: 1,
348
- content: '3MESSAGE',
349
- },
350
- {
351
- id: 4,
352
- authorId: 5,
353
- content: '1MESSAGE',
354
- },
355
- {
356
- id: 5,
357
- authorId: 5,
358
- content: '2MESSAGE',
359
- },
360
- {
361
- id: 6,
362
- authorId: 1,
363
- content: '4MESSAGE',
364
- },
365
- ],
366
- },
367
- });
368
- });
369
-
370
- it(`Select single with relations`, async () => {
371
- const res = await ctx.gql.queryGql(/* GraphQL */ `
372
- {
373
- usersSingle {
374
- id
375
- name
376
- email
377
- textJson
378
- blobBigInt
379
- numeric
380
- createdAt
381
- createdAtMs
382
- real
383
- text
384
- role
385
- isConfirmed
386
- posts {
387
- id
388
- authorId
389
- content
390
- }
391
- }
392
-
393
- postsSingle {
394
- id
395
- authorId
396
- content
397
- author {
398
- id
399
- name
400
- email
401
- textJson
402
- numeric
403
- createdAt
404
- createdAtMs
405
- real
406
- text
407
- role
408
- isConfirmed
409
- }
410
- }
411
- }
412
- `);
413
-
414
- expect(res).toStrictEqual({
415
- data: {
416
- usersSingle: {
417
- id: 1,
418
- name: 'FirstUser',
419
- email: 'userOne@notmail.com',
420
- textJson: '{"field":"value"}',
421
- blobBigInt: '10',
422
- numeric: '250.2',
423
- createdAt: '2024-04-02T06:44:41.000Z',
424
- createdAtMs: '2024-04-02T06:44:41.785Z',
425
- real: 13.5,
426
- text: 'sometext',
427
- role: 'admin',
428
- isConfirmed: true,
429
- posts: [
430
- {
431
- id: 1,
432
- authorId: 1,
433
- content: '1MESSAGE',
434
- },
435
- {
436
- id: 2,
437
- authorId: 1,
438
- content: '2MESSAGE',
439
- },
440
- {
441
- id: 3,
442
- authorId: 1,
443
- content: '3MESSAGE',
444
- },
445
-
446
- {
447
- id: 6,
448
- authorId: 1,
449
- content: '4MESSAGE',
450
- },
451
- ],
452
- },
453
- postsSingle: {
454
- id: 1,
455
- authorId: 1,
456
- content: '1MESSAGE',
457
- author: {
458
- id: 1,
459
- name: 'FirstUser',
460
- email: 'userOne@notmail.com',
461
- textJson: '{"field":"value"}',
462
- // RQB can't handle blobs in JSON, for now
463
- // blobBigInt: '10',
464
- numeric: '250.2',
465
- createdAt: '2024-04-02T06:44:41.000Z',
466
- createdAtMs: '2024-04-02T06:44:41.785Z',
467
- real: 13.5,
468
- text: 'sometext',
469
- role: 'admin',
470
- isConfirmed: true,
471
- },
472
- },
473
- },
474
- });
475
- });
476
-
477
- it(`Select array with relations`, async () => {
478
- const res = await ctx.gql.queryGql(/* GraphQL */ `
479
- {
480
- users {
481
- id
482
- name
483
- email
484
- textJson
485
- blobBigInt
486
- numeric
487
- createdAt
488
- createdAtMs
489
- real
490
- text
491
- role
492
- isConfirmed
493
- posts {
494
- id
495
- authorId
496
- content
497
- }
498
- }
499
-
500
- posts {
501
- id
502
- authorId
503
- content
504
- author {
505
- id
506
- name
507
- email
508
- textJson
509
- numeric
510
- createdAt
511
- createdAtMs
512
- real
513
- text
514
- role
515
- isConfirmed
516
- }
517
- }
518
- }
519
- `);
520
-
521
- expect(res).toStrictEqual({
522
- data: {
523
- users: [
524
- {
525
- id: 1,
526
- name: 'FirstUser',
527
- email: 'userOne@notmail.com',
528
- textJson: '{"field":"value"}',
529
- blobBigInt: '10',
530
- numeric: '250.2',
531
- createdAt: '2024-04-02T06:44:41.000Z',
532
- createdAtMs: '2024-04-02T06:44:41.785Z',
533
- real: 13.5,
534
- text: 'sometext',
535
- role: 'admin',
536
- isConfirmed: true,
537
- posts: [
538
- {
539
- id: 1,
540
- authorId: 1,
541
- content: '1MESSAGE',
542
- },
543
- {
544
- id: 2,
545
- authorId: 1,
546
- content: '2MESSAGE',
547
- },
548
- {
549
- id: 3,
550
- authorId: 1,
551
- content: '3MESSAGE',
552
- },
553
- {
554
- id: 6,
555
- authorId: 1,
556
- content: '4MESSAGE',
557
- },
558
- ],
559
- },
560
- {
561
- id: 2,
562
- name: 'SecondUser',
563
- email: null,
564
- textJson: null,
565
- blobBigInt: null,
566
- numeric: null,
567
- createdAt: '2024-04-02T06:44:41.000Z',
568
- createdAtMs: null,
569
- real: null,
570
- text: null,
571
- role: 'user',
572
- isConfirmed: null,
573
- posts: [],
574
- },
575
- {
576
- id: 5,
577
- name: 'FifthUser',
578
- email: null,
579
- textJson: null,
580
- blobBigInt: null,
581
- numeric: null,
582
- createdAt: '2024-04-02T06:44:41.000Z',
583
- createdAtMs: null,
584
- real: null,
585
- text: null,
586
- role: 'user',
587
- isConfirmed: null,
588
- posts: [
589
- {
590
- id: 4,
591
- authorId: 5,
592
- content: '1MESSAGE',
593
- },
594
- {
595
- id: 5,
596
- authorId: 5,
597
- content: '2MESSAGE',
598
- },
599
- ],
600
- },
601
- ],
602
- posts: [
603
- {
604
- id: 1,
605
- authorId: 1,
606
- content: '1MESSAGE',
607
- author: {
608
- id: 1,
609
- name: 'FirstUser',
610
- email: 'userOne@notmail.com',
611
- textJson: '{"field":"value"}',
612
- // RQB can't handle blobs in JSON, for now
613
- // blobBigInt: '10',
614
- numeric: '250.2',
615
- createdAt: '2024-04-02T06:44:41.000Z',
616
- createdAtMs: '2024-04-02T06:44:41.785Z',
617
- real: 13.5,
618
- text: 'sometext',
619
- role: 'admin',
620
- isConfirmed: true,
621
- },
622
- },
623
- {
624
- id: 2,
625
- authorId: 1,
626
- content: '2MESSAGE',
627
- author: {
628
- id: 1,
629
- name: 'FirstUser',
630
- email: 'userOne@notmail.com',
631
- textJson: '{"field":"value"}',
632
- // RQB can't handle blobs in JSON, for now
633
- // blobBigInt: '10',
634
- numeric: '250.2',
635
- createdAt: '2024-04-02T06:44:41.000Z',
636
- createdAtMs: '2024-04-02T06:44:41.785Z',
637
- real: 13.5,
638
- text: 'sometext',
639
- role: 'admin',
640
- isConfirmed: true,
641
- },
642
- },
643
- {
644
- id: 3,
645
- authorId: 1,
646
- content: '3MESSAGE',
647
- author: {
648
- id: 1,
649
- name: 'FirstUser',
650
- email: 'userOne@notmail.com',
651
- textJson: '{"field":"value"}',
652
- // RQB can't handle blobs in JSON, for now
653
- // blobBigInt: '10',
654
- numeric: '250.2',
655
- createdAt: '2024-04-02T06:44:41.000Z',
656
- createdAtMs: '2024-04-02T06:44:41.785Z',
657
- real: 13.5,
658
- text: 'sometext',
659
- role: 'admin',
660
- isConfirmed: true,
661
- },
662
- },
663
- {
664
- id: 4,
665
- authorId: 5,
666
- content: '1MESSAGE',
667
- author: {
668
- id: 5,
669
- name: 'FifthUser',
670
- email: null,
671
- textJson: null,
672
- // RQB can't handle blobs in JSON, for now
673
- // blobBigInt: null,
674
- numeric: null,
675
- createdAt: '2024-04-02T06:44:41.000Z',
676
- createdAtMs: null,
677
- real: null,
678
- text: null,
679
- role: 'user',
680
- isConfirmed: null,
681
- },
682
- },
683
- {
684
- id: 5,
685
- authorId: 5,
686
- content: '2MESSAGE',
687
- author: {
688
- id: 5,
689
- name: 'FifthUser',
690
- email: null,
691
- textJson: null,
692
- // RQB can't handle blobs in JSON, for now
693
- // blobBigInt: null,
694
- numeric: null,
695
- createdAt: '2024-04-02T06:44:41.000Z',
696
- createdAtMs: null,
697
- real: null,
698
- text: null,
699
- role: 'user',
700
- isConfirmed: null,
701
- },
702
- },
703
- {
704
- id: 6,
705
- authorId: 1,
706
- content: '4MESSAGE',
707
- author: {
708
- id: 1,
709
- name: 'FirstUser',
710
- email: 'userOne@notmail.com',
711
- textJson: '{"field":"value"}',
712
- // RQB can't handle blobs in JSON, for now
713
- // blobBigInt: '10',
714
- numeric: '250.2',
715
- createdAt: '2024-04-02T06:44:41.000Z',
716
- createdAtMs: '2024-04-02T06:44:41.785Z',
717
- real: 13.5,
718
- text: 'sometext',
719
- role: 'admin',
720
- isConfirmed: true,
721
- },
722
- },
723
- ],
724
- },
725
- });
726
- });
727
-
728
- it(`Select single by fragment`, async () => {
729
- const res = await ctx.gql.queryGql(/* GraphQL */ `
730
- query testQuery {
731
- usersSingle {
732
- ...UsersFrag
733
- }
734
-
735
- postsSingle {
736
- ...PostsFrag
737
- }
738
- }
739
-
740
- fragment UsersFrag on UsersSelectItem {
741
- id
742
- name
743
- email
744
- textJson
745
- blobBigInt
746
- numeric
747
- createdAt
748
- createdAtMs
749
- real
750
- text
751
- role
752
- isConfirmed
753
- }
754
-
755
- fragment PostsFrag on PostsSelectItem {
756
- id
757
- authorId
758
- content
759
- }
760
- `);
761
-
762
- expect(res).toStrictEqual({
763
- data: {
764
- usersSingle: {
765
- id: 1,
766
- name: 'FirstUser',
767
- email: 'userOne@notmail.com',
768
- textJson: '{"field":"value"}',
769
- blobBigInt: '10',
770
- numeric: '250.2',
771
- createdAt: '2024-04-02T06:44:41.000Z',
772
- createdAtMs: '2024-04-02T06:44:41.785Z',
773
- real: 13.5,
774
- text: 'sometext',
775
- role: 'admin',
776
- isConfirmed: true,
777
- },
778
- postsSingle: {
779
- id: 1,
780
- authorId: 1,
781
- content: '1MESSAGE',
782
- },
783
- },
784
- });
785
- });
786
-
787
- it(`Select array by fragment`, async () => {
788
- const res = await ctx.gql.queryGql(/* GraphQL */ `
789
- query testQuery {
790
- users {
791
- ...UsersFrag
792
- }
793
-
794
- posts {
795
- ...PostsFrag
796
- }
797
- }
798
-
799
- fragment UsersFrag on UsersSelectItem {
800
- id
801
- name
802
- email
803
- textJson
804
- blobBigInt
805
- numeric
806
- createdAt
807
- createdAtMs
808
- real
809
- text
810
- role
811
- isConfirmed
812
- }
813
-
814
- fragment PostsFrag on PostsSelectItem {
815
- id
816
- authorId
817
- content
818
- }
819
- `);
820
-
821
- expect(res).toStrictEqual({
822
- data: {
823
- users: [
824
- {
825
- id: 1,
826
- name: 'FirstUser',
827
- email: 'userOne@notmail.com',
828
- textJson: '{"field":"value"}',
829
- blobBigInt: '10',
830
- numeric: '250.2',
831
- createdAt: '2024-04-02T06:44:41.000Z',
832
- createdAtMs: '2024-04-02T06:44:41.785Z',
833
- real: 13.5,
834
- text: 'sometext',
835
- role: 'admin',
836
- isConfirmed: true,
837
- },
838
- {
839
- id: 2,
840
- name: 'SecondUser',
841
- email: null,
842
- blobBigInt: null,
843
- textJson: null,
844
- createdAt: '2024-04-02T06:44:41.000Z',
845
- createdAtMs: null,
846
- numeric: null,
847
- real: null,
848
- text: null,
849
- role: 'user',
850
- isConfirmed: null,
851
- },
852
- {
853
- id: 5,
854
- name: 'FifthUser',
855
- email: null,
856
- createdAt: '2024-04-02T06:44:41.000Z',
857
- role: 'user',
858
- blobBigInt: null,
859
- textJson: null,
860
- createdAtMs: null,
861
- numeric: null,
862
- real: null,
863
- text: null,
864
- isConfirmed: null,
865
- },
866
- ],
867
- posts: [
868
- {
869
- id: 1,
870
- authorId: 1,
871
- content: '1MESSAGE',
872
- },
873
- {
874
- id: 2,
875
- authorId: 1,
876
- content: '2MESSAGE',
877
- },
878
- {
879
- id: 3,
880
- authorId: 1,
881
- content: '3MESSAGE',
882
- },
883
- {
884
- id: 4,
885
- authorId: 5,
886
- content: '1MESSAGE',
887
- },
888
- {
889
- id: 5,
890
- authorId: 5,
891
- content: '2MESSAGE',
892
- },
893
- {
894
- id: 6,
895
- authorId: 1,
896
- content: '4MESSAGE',
897
- },
898
- ],
899
- },
900
- });
901
- });
902
-
903
- it(`Select single with relations by fragment`, async () => {
904
- const res = await ctx.gql.queryGql(/* GraphQL */ `
905
- query testQuery {
906
- usersSingle {
907
- ...UsersFrag
908
- }
909
-
910
- postsSingle {
911
- ...PostsFrag
912
- }
913
- }
914
-
915
- fragment UsersFrag on UsersSelectItem {
916
- id
917
- name
918
- email
919
- textJson
920
- blobBigInt
921
- numeric
922
- createdAt
923
- createdAtMs
924
- real
925
- text
926
- role
927
- isConfirmed
928
- posts {
929
- id
930
- authorId
931
- content
932
- }
933
- }
934
-
935
- fragment PostsFrag on PostsSelectItem {
936
- id
937
- authorId
938
- content
939
- author {
940
- id
941
- name
942
- email
943
- textJson
944
- numeric
945
- createdAt
946
- createdAtMs
947
- real
948
- text
949
- role
950
- isConfirmed
951
- }
952
- }
953
- `);
954
-
955
- expect(res).toStrictEqual({
956
- data: {
957
- usersSingle: {
958
- id: 1,
959
- name: 'FirstUser',
960
- email: 'userOne@notmail.com',
961
- textJson: '{"field":"value"}',
962
- blobBigInt: '10',
963
- numeric: '250.2',
964
- createdAt: '2024-04-02T06:44:41.000Z',
965
- createdAtMs: '2024-04-02T06:44:41.785Z',
966
- real: 13.5,
967
- text: 'sometext',
968
- role: 'admin',
969
- isConfirmed: true,
970
- posts: [
971
- {
972
- id: 1,
973
- authorId: 1,
974
- content: '1MESSAGE',
975
- },
976
- {
977
- id: 2,
978
- authorId: 1,
979
- content: '2MESSAGE',
980
- },
981
- {
982
- id: 3,
983
- authorId: 1,
984
- content: '3MESSAGE',
985
- },
986
-
987
- {
988
- id: 6,
989
- authorId: 1,
990
- content: '4MESSAGE',
991
- },
992
- ],
993
- },
994
- postsSingle: {
995
- id: 1,
996
- authorId: 1,
997
- content: '1MESSAGE',
998
- author: {
999
- id: 1,
1000
- name: 'FirstUser',
1001
- email: 'userOne@notmail.com',
1002
- textJson: '{"field":"value"}',
1003
- // RQB can't handle blobs in JSON, for now
1004
- // blobBigInt: '10',
1005
- numeric: '250.2',
1006
- createdAt: '2024-04-02T06:44:41.000Z',
1007
- createdAtMs: '2024-04-02T06:44:41.785Z',
1008
- real: 13.5,
1009
- text: 'sometext',
1010
- role: 'admin',
1011
- isConfirmed: true,
1012
- },
1013
- },
1014
- },
1015
- });
1016
- });
1017
-
1018
- it(`Select array with relations by fragment`, async () => {
1019
- const res = await ctx.gql.queryGql(/* GraphQL */ `
1020
- query testQuery {
1021
- users {
1022
- ...UsersFrag
1023
- }
1024
-
1025
- posts {
1026
- ...PostsFrag
1027
- }
1028
- }
1029
-
1030
- fragment UsersFrag on UsersSelectItem {
1031
- id
1032
- name
1033
- email
1034
- textJson
1035
- blobBigInt
1036
- numeric
1037
- createdAt
1038
- createdAtMs
1039
- real
1040
- text
1041
- role
1042
- isConfirmed
1043
- posts {
1044
- id
1045
- authorId
1046
- content
1047
- }
1048
- }
1049
-
1050
- fragment PostsFrag on PostsSelectItem {
1051
- id
1052
- authorId
1053
- content
1054
- author {
1055
- id
1056
- name
1057
- email
1058
- textJson
1059
- numeric
1060
- createdAt
1061
- createdAtMs
1062
- real
1063
- text
1064
- role
1065
- isConfirmed
1066
- }
1067
- }
1068
- `);
1069
-
1070
- expect(res).toStrictEqual({
1071
- data: {
1072
- users: [
1073
- {
1074
- id: 1,
1075
- name: 'FirstUser',
1076
- email: 'userOne@notmail.com',
1077
- textJson: '{"field":"value"}',
1078
- blobBigInt: '10',
1079
- numeric: '250.2',
1080
- createdAt: '2024-04-02T06:44:41.000Z',
1081
- createdAtMs: '2024-04-02T06:44:41.785Z',
1082
- real: 13.5,
1083
- text: 'sometext',
1084
- role: 'admin',
1085
- isConfirmed: true,
1086
- posts: [
1087
- {
1088
- id: 1,
1089
- authorId: 1,
1090
- content: '1MESSAGE',
1091
- },
1092
- {
1093
- id: 2,
1094
- authorId: 1,
1095
- content: '2MESSAGE',
1096
- },
1097
- {
1098
- id: 3,
1099
- authorId: 1,
1100
- content: '3MESSAGE',
1101
- },
1102
- {
1103
- id: 6,
1104
- authorId: 1,
1105
- content: '4MESSAGE',
1106
- },
1107
- ],
1108
- },
1109
- {
1110
- id: 2,
1111
- name: 'SecondUser',
1112
- email: null,
1113
- textJson: null,
1114
- blobBigInt: null,
1115
- numeric: null,
1116
- createdAt: '2024-04-02T06:44:41.000Z',
1117
- createdAtMs: null,
1118
- real: null,
1119
- text: null,
1120
- role: 'user',
1121
- isConfirmed: null,
1122
- posts: [],
1123
- },
1124
- {
1125
- id: 5,
1126
- name: 'FifthUser',
1127
- email: null,
1128
- textJson: null,
1129
- blobBigInt: null,
1130
- numeric: null,
1131
- createdAt: '2024-04-02T06:44:41.000Z',
1132
- createdAtMs: null,
1133
- real: null,
1134
- text: null,
1135
- role: 'user',
1136
- isConfirmed: null,
1137
- posts: [
1138
- {
1139
- id: 4,
1140
- authorId: 5,
1141
- content: '1MESSAGE',
1142
- },
1143
- {
1144
- id: 5,
1145
- authorId: 5,
1146
- content: '2MESSAGE',
1147
- },
1148
- ],
1149
- },
1150
- ],
1151
- posts: [
1152
- {
1153
- id: 1,
1154
- authorId: 1,
1155
- content: '1MESSAGE',
1156
- author: {
1157
- id: 1,
1158
- name: 'FirstUser',
1159
- email: 'userOne@notmail.com',
1160
- textJson: '{"field":"value"}',
1161
- // RQB can't handle blobs in JSON, for now
1162
- // blobBigInt: '10',
1163
- numeric: '250.2',
1164
- createdAt: '2024-04-02T06:44:41.000Z',
1165
- createdAtMs: '2024-04-02T06:44:41.785Z',
1166
- real: 13.5,
1167
- text: 'sometext',
1168
- role: 'admin',
1169
- isConfirmed: true,
1170
- },
1171
- },
1172
- {
1173
- id: 2,
1174
- authorId: 1,
1175
- content: '2MESSAGE',
1176
- author: {
1177
- id: 1,
1178
- name: 'FirstUser',
1179
- email: 'userOne@notmail.com',
1180
- textJson: '{"field":"value"}',
1181
- // RQB can't handle blobs in JSON, for now
1182
- // blobBigInt: '10',
1183
- numeric: '250.2',
1184
- createdAt: '2024-04-02T06:44:41.000Z',
1185
- createdAtMs: '2024-04-02T06:44:41.785Z',
1186
- real: 13.5,
1187
- text: 'sometext',
1188
- role: 'admin',
1189
- isConfirmed: true,
1190
- },
1191
- },
1192
- {
1193
- id: 3,
1194
- authorId: 1,
1195
- content: '3MESSAGE',
1196
- author: {
1197
- id: 1,
1198
- name: 'FirstUser',
1199
- email: 'userOne@notmail.com',
1200
- textJson: '{"field":"value"}',
1201
- // RQB can't handle blobs in JSON, for now
1202
- // blobBigInt: '10',
1203
- numeric: '250.2',
1204
- createdAt: '2024-04-02T06:44:41.000Z',
1205
- createdAtMs: '2024-04-02T06:44:41.785Z',
1206
- real: 13.5,
1207
- text: 'sometext',
1208
- role: 'admin',
1209
- isConfirmed: true,
1210
- },
1211
- },
1212
- {
1213
- id: 4,
1214
- authorId: 5,
1215
- content: '1MESSAGE',
1216
- author: {
1217
- id: 5,
1218
- name: 'FifthUser',
1219
- email: null,
1220
- textJson: null,
1221
- // RQB can't handle blobs in JSON, for now
1222
- // blobBigInt: null,
1223
- numeric: null,
1224
- createdAt: '2024-04-02T06:44:41.000Z',
1225
- createdAtMs: null,
1226
- real: null,
1227
- text: null,
1228
- role: 'user',
1229
- isConfirmed: null,
1230
- },
1231
- },
1232
- {
1233
- id: 5,
1234
- authorId: 5,
1235
- content: '2MESSAGE',
1236
- author: {
1237
- id: 5,
1238
- name: 'FifthUser',
1239
- email: null,
1240
- textJson: null,
1241
- // RQB can't handle blobs in JSON, for now
1242
- // blobBigInt: null,
1243
- numeric: null,
1244
- createdAt: '2024-04-02T06:44:41.000Z',
1245
- createdAtMs: null,
1246
- real: null,
1247
- text: null,
1248
- role: 'user',
1249
- isConfirmed: null,
1250
- },
1251
- },
1252
- {
1253
- id: 6,
1254
- authorId: 1,
1255
- content: '4MESSAGE',
1256
- author: {
1257
- id: 1,
1258
- name: 'FirstUser',
1259
- email: 'userOne@notmail.com',
1260
- textJson: '{"field":"value"}',
1261
- // RQB can't handle blobs in JSON, for now
1262
- // blobBigInt: '10',
1263
- numeric: '250.2',
1264
- createdAt: '2024-04-02T06:44:41.000Z',
1265
- createdAtMs: '2024-04-02T06:44:41.785Z',
1266
- real: 13.5,
1267
- text: 'sometext',
1268
- role: 'admin',
1269
- isConfirmed: true,
1270
- },
1271
- },
1272
- ],
1273
- },
1274
- });
1275
- });
1276
-
1277
- it(`Insert single`, async () => {
1278
- const res = await ctx.gql.queryGql(/* GraphQL */ `
1279
- mutation {
1280
- insertIntoUsersSingle(
1281
- values: {
1282
- id: 3
1283
- name: "ThirdUser"
1284
- email: "userThree@notmail.com"
1285
- textJson: "{ \\"field\\": \\"value\\" }"
1286
- blobBigInt: "10"
1287
- numeric: "250.2"
1288
- createdAt: "2024-04-02T06:44:41.785Z"
1289
- createdAtMs: "2024-04-02T06:44:41.785Z"
1290
- real: 13.5
1291
- text: "sometext"
1292
- role: admin
1293
- isConfirmed: true
1294
- }
1295
- ) {
1296
- id
1297
- name
1298
- email
1299
- textJson
1300
- blobBigInt
1301
- numeric
1302
- createdAt
1303
- createdAtMs
1304
- real
1305
- text
1306
- role
1307
- isConfirmed
1308
- }
1309
- }
1310
- `);
1311
-
1312
- expect(res).toStrictEqual({
1313
- data: {
1314
- insertIntoUsersSingle: {
1315
- id: 3,
1316
- name: 'ThirdUser',
1317
- email: 'userThree@notmail.com',
1318
- textJson: '{"field":"value"}',
1319
- blobBigInt: '10',
1320
- numeric: '250.2',
1321
- createdAt: '2024-04-02T06:44:41.000Z',
1322
- createdAtMs: '2024-04-02T06:44:41.785Z',
1323
- real: 13.5,
1324
- text: 'sometext',
1325
- role: 'admin',
1326
- isConfirmed: true,
1327
- },
1328
- },
1329
- });
1330
- });
1331
-
1332
- it(`Insert array`, async () => {
1333
- const res = await ctx.gql.queryGql(/* GraphQL */ `
1334
- mutation {
1335
- insertIntoUsers(
1336
- values: [
1337
- {
1338
- id: 3
1339
- name: "ThirdUser"
1340
- email: "userThree@notmail.com"
1341
- textJson: "{ \\"field\\": \\"value\\" }"
1342
- blobBigInt: "10"
1343
- numeric: "250.2"
1344
- createdAt: "2024-04-02T06:44:41.785Z"
1345
- createdAtMs: "2024-04-02T06:44:41.785Z"
1346
- real: 13.5
1347
- text: "sometext"
1348
- role: admin
1349
- isConfirmed: true
1350
- }
1351
- {
1352
- id: 4
1353
- name: "FourthUser"
1354
- email: "userFour@notmail.com"
1355
- textJson: "{ \\"field\\": \\"value\\" }"
1356
- blobBigInt: "10"
1357
- numeric: "250.2"
1358
- createdAt: "2024-04-02T06:44:41.785Z"
1359
- createdAtMs: "2024-04-02T06:44:41.785Z"
1360
- real: 13.5
1361
- text: "sometext"
1362
- role: user
1363
- isConfirmed: false
1364
- }
1365
- ]
1366
- ) {
1367
- id
1368
- name
1369
- email
1370
- textJson
1371
- blobBigInt
1372
- numeric
1373
- createdAt
1374
- createdAtMs
1375
- real
1376
- text
1377
- role
1378
- isConfirmed
1379
- }
1380
- }
1381
- `);
1382
-
1383
- expect(res).toStrictEqual({
1384
- data: {
1385
- insertIntoUsers: [
1386
- {
1387
- id: 3,
1388
- name: 'ThirdUser',
1389
- email: 'userThree@notmail.com',
1390
- textJson: '{"field":"value"}',
1391
- blobBigInt: '10',
1392
- numeric: '250.2',
1393
- createdAt: '2024-04-02T06:44:41.000Z',
1394
- createdAtMs: '2024-04-02T06:44:41.785Z',
1395
- real: 13.5,
1396
- text: 'sometext',
1397
- role: 'admin',
1398
- isConfirmed: true,
1399
- },
1400
- {
1401
- id: 4,
1402
- name: 'FourthUser',
1403
- email: 'userFour@notmail.com',
1404
- textJson: '{"field":"value"}',
1405
- blobBigInt: '10',
1406
- numeric: '250.2',
1407
- createdAt: '2024-04-02T06:44:41.000Z',
1408
- createdAtMs: '2024-04-02T06:44:41.785Z',
1409
- real: 13.5,
1410
- text: 'sometext',
1411
- role: 'user',
1412
- isConfirmed: false,
1413
- },
1414
- ],
1415
- },
1416
- });
1417
- });
1418
-
1419
- it(`Update`, async () => {
1420
- const res = await ctx.gql.queryGql(/* GraphQL */ `
1421
- mutation {
1422
- updateCustomers(set: { isConfirmed: true, address: "Edited" }) {
1423
- id
1424
- address
1425
- isConfirmed
1426
- registrationDate
1427
- userId
1428
- }
1429
- }
1430
- `);
1431
-
1432
- expect(res).toStrictEqual({
1433
- data: {
1434
- updateCustomers: [
1435
- {
1436
- id: 1,
1437
- address: 'Edited',
1438
- isConfirmed: true,
1439
- registrationDate: '2024-03-27T03:54:45.235Z',
1440
- userId: 1,
1441
- },
1442
- {
1443
- id: 2,
1444
- address: 'Edited',
1445
- isConfirmed: true,
1446
- registrationDate: '2024-03-27T03:55:42.358Z',
1447
- userId: 2,
1448
- },
1449
- ],
1450
- },
1451
- });
1452
- });
1453
-
1454
- it(`Delete`, async () => {
1455
- const res = await ctx.gql.queryGql(/* GraphQL */ `
1456
- mutation {
1457
- deleteFromCustomers {
1458
- id
1459
- address
1460
- isConfirmed
1461
- registrationDate
1462
- userId
1463
- }
1464
- }
1465
- `);
1466
-
1467
- expect(res).toStrictEqual({
1468
- data: {
1469
- deleteFromCustomers: [
1470
- {
1471
- id: 1,
1472
- address: 'AdOne',
1473
- isConfirmed: false,
1474
- registrationDate: '2024-03-27T03:54:45.235Z',
1475
- userId: 1,
1476
- },
1477
- {
1478
- id: 2,
1479
- address: 'AdTwo',
1480
- isConfirmed: false,
1481
- registrationDate: '2024-03-27T03:55:42.358Z',
1482
- userId: 2,
1483
- },
1484
- ],
1485
- },
1486
- });
1487
- });
1488
- });
1489
-
1490
- describe.sequential('Arguments tests', async () => {
1491
- it('Order by', async () => {
1492
- const res = await ctx.gql.queryGql(/* GraphQL */ `
1493
- {
1494
- posts(
1495
- orderBy: { authorId: { priority: 1, direction: desc }, content: { priority: 0, direction: asc } }
1496
- ) {
1497
- id
1498
- authorId
1499
- content
1500
- }
1501
- }
1502
- `);
1503
-
1504
- expect(res).toStrictEqual({
1505
- data: {
1506
- posts: [
1507
- {
1508
- id: 4,
1509
- authorId: 5,
1510
- content: '1MESSAGE',
1511
- },
1512
- {
1513
- id: 5,
1514
- authorId: 5,
1515
- content: '2MESSAGE',
1516
- },
1517
- {
1518
- id: 1,
1519
- authorId: 1,
1520
- content: '1MESSAGE',
1521
- },
1522
- {
1523
- id: 2,
1524
- authorId: 1,
1525
- content: '2MESSAGE',
1526
- },
1527
- {
1528
- id: 3,
1529
- authorId: 1,
1530
- content: '3MESSAGE',
1531
- },
1532
-
1533
- {
1534
- id: 6,
1535
- authorId: 1,
1536
- content: '4MESSAGE',
1537
- },
1538
- ],
1539
- },
1540
- });
1541
- });
1542
-
1543
- it('Order by on single', async () => {
1544
- const res = await ctx.gql.queryGql(/* GraphQL */ `
1545
- {
1546
- postsSingle(
1547
- orderBy: { authorId: { priority: 1, direction: desc }, content: { priority: 0, direction: asc } }
1548
- ) {
1549
- id
1550
- authorId
1551
- content
1552
- }
1553
- }
1554
- `);
1555
-
1556
- expect(res).toStrictEqual({
1557
- data: {
1558
- postsSingle: {
1559
- id: 4,
1560
- authorId: 5,
1561
- content: '1MESSAGE',
1562
- },
1563
- },
1564
- });
1565
- });
1566
-
1567
- it('Offset & limit', async () => {
1568
- const res = await ctx.gql.queryGql(/* GraphQL */ `
1569
- {
1570
- posts(offset: 1, limit: 2) {
1571
- id
1572
- authorId
1573
- content
1574
- }
1575
- }
1576
- `);
1577
-
1578
- expect(res).toStrictEqual({
1579
- data: {
1580
- posts: [
1581
- {
1582
- id: 2,
1583
- authorId: 1,
1584
- content: '2MESSAGE',
1585
- },
1586
- {
1587
- id: 3,
1588
- authorId: 1,
1589
- content: '3MESSAGE',
1590
- },
1591
- ],
1592
- },
1593
- });
1594
- });
1595
-
1596
- it('Offset on single', async () => {
1597
- const res = await ctx.gql.queryGql(/* GraphQL */ `
1598
- {
1599
- postsSingle(offset: 1) {
1600
- id
1601
- authorId
1602
- content
1603
- }
1604
- }
1605
- `);
1606
-
1607
- expect(res).toStrictEqual({
1608
- data: {
1609
- postsSingle: {
1610
- id: 2,
1611
- authorId: 1,
1612
- content: '2MESSAGE',
1613
- },
1614
- },
1615
- });
1616
- });
1617
-
1618
- it('Filters - top level AND', async () => {
1619
- const res = await ctx.gql.queryGql(/* GraphQL */ `
1620
- {
1621
- posts(where: { id: { inArray: [2, 3, 4, 5, 6] }, authorId: { ne: 5 }, content: { ne: "3MESSAGE" } }) {
1622
- id
1623
- authorId
1624
- content
1625
- }
1626
- }
1627
- `);
1628
-
1629
- expect(res).toStrictEqual({
1630
- data: {
1631
- posts: [
1632
- {
1633
- id: 2,
1634
- authorId: 1,
1635
- content: '2MESSAGE',
1636
- },
1637
- {
1638
- id: 6,
1639
- authorId: 1,
1640
- content: '4MESSAGE',
1641
- },
1642
- ],
1643
- },
1644
- });
1645
- });
1646
-
1647
- it('Filters - top level OR', async () => {
1648
- const res = await ctx.gql.queryGql(/* GraphQL */ `
1649
- {
1650
- posts(where: { OR: [{ id: { lte: 3 } }, { authorId: { eq: 5 } }] }) {
1651
- id
1652
- authorId
1653
- content
1654
- }
1655
- }
1656
- `);
1657
-
1658
- expect(res).toStrictEqual({
1659
- data: {
1660
- posts: [
1661
- {
1662
- id: 1,
1663
- authorId: 1,
1664
- content: '1MESSAGE',
1665
- },
1666
- {
1667
- id: 2,
1668
- authorId: 1,
1669
- content: '2MESSAGE',
1670
- },
1671
- {
1672
- id: 3,
1673
- authorId: 1,
1674
- content: '3MESSAGE',
1675
- },
1676
- {
1677
- id: 4,
1678
- authorId: 5,
1679
- content: '1MESSAGE',
1680
- },
1681
- {
1682
- id: 5,
1683
- authorId: 5,
1684
- content: '2MESSAGE',
1685
- },
1686
- ],
1687
- },
1688
- });
1689
- });
1690
-
1691
- it('Update filters', async () => {
1692
- const res = await ctx.gql.queryGql(/* GraphQL */ `
1693
- mutation {
1694
- updatePosts(where: { OR: [{ id: { lte: 3 } }, { authorId: { eq: 5 } }] }, set: { content: "UPDATED" }) {
1695
- id
1696
- authorId
1697
- content
1698
- }
1699
- }
1700
- `);
1701
-
1702
- expect(res).toStrictEqual({
1703
- data: {
1704
- updatePosts: [
1705
- {
1706
- id: 1,
1707
- authorId: 1,
1708
- content: 'UPDATED',
1709
- },
1710
- {
1711
- id: 2,
1712
- authorId: 1,
1713
- content: 'UPDATED',
1714
- },
1715
- {
1716
- id: 3,
1717
- authorId: 1,
1718
- content: 'UPDATED',
1719
- },
1720
- {
1721
- id: 4,
1722
- authorId: 5,
1723
- content: 'UPDATED',
1724
- },
1725
- {
1726
- id: 5,
1727
- authorId: 5,
1728
- content: 'UPDATED',
1729
- },
1730
- ],
1731
- },
1732
- });
1733
- });
1734
-
1735
- it('Delete filters', async () => {
1736
- const res = await ctx.gql.queryGql(/* GraphQL */ `
1737
- mutation {
1738
- deleteFromPosts(where: { OR: [{ id: { lte: 3 } }, { authorId: { eq: 5 } }] }) {
1739
- id
1740
- authorId
1741
- content
1742
- }
1743
- }
1744
- `);
1745
-
1746
- expect(res).toStrictEqual({
1747
- data: {
1748
- deleteFromPosts: [
1749
- {
1750
- id: 1,
1751
- authorId: 1,
1752
- content: '1MESSAGE',
1753
- },
1754
- {
1755
- id: 2,
1756
- authorId: 1,
1757
- content: '2MESSAGE',
1758
- },
1759
- {
1760
- id: 3,
1761
- authorId: 1,
1762
- content: '3MESSAGE',
1763
- },
1764
- {
1765
- id: 4,
1766
- authorId: 5,
1767
- content: '1MESSAGE',
1768
- },
1769
- {
1770
- id: 5,
1771
- authorId: 5,
1772
- content: '2MESSAGE',
1773
- },
1774
- ],
1775
- },
1776
- });
1777
- });
1778
-
1779
- it('Relations orderBy', async () => {
1780
- const res = await ctx.gql.queryGql(/* GraphQL */ `
1781
- {
1782
- users {
1783
- id
1784
- posts(orderBy: { id: { priority: 1, direction: desc } }) {
1785
- id
1786
- authorId
1787
- content
1788
- }
1789
- }
1790
- }
1791
- `);
1792
-
1793
- expect(res).toStrictEqual({
1794
- data: {
1795
- users: [
1796
- {
1797
- id: 1,
1798
- posts: [
1799
- {
1800
- id: 6,
1801
- authorId: 1,
1802
- content: '4MESSAGE',
1803
- },
1804
- {
1805
- id: 3,
1806
- authorId: 1,
1807
- content: '3MESSAGE',
1808
- },
1809
- {
1810
- id: 2,
1811
- authorId: 1,
1812
- content: '2MESSAGE',
1813
- },
1814
- {
1815
- id: 1,
1816
- authorId: 1,
1817
- content: '1MESSAGE',
1818
- },
1819
- ],
1820
- },
1821
- {
1822
- id: 2,
1823
- posts: [],
1824
- },
1825
- {
1826
- id: 5,
1827
- posts: [
1828
- {
1829
- id: 5,
1830
- authorId: 5,
1831
- content: '2MESSAGE',
1832
- },
1833
- {
1834
- id: 4,
1835
- authorId: 5,
1836
- content: '1MESSAGE',
1837
- },
1838
- ],
1839
- },
1840
- ],
1841
- },
1842
- });
1843
- });
1844
-
1845
- it('Relations offset & limit', async () => {
1846
- const res = await ctx.gql.queryGql(/* GraphQL */ `
1847
- {
1848
- users {
1849
- id
1850
- posts(offset: 1, limit: 2) {
1851
- id
1852
- authorId
1853
- content
1854
- }
1855
- }
1856
- }
1857
- `);
1858
-
1859
- expect(res).toStrictEqual({
1860
- data: {
1861
- users: [
1862
- {
1863
- id: 1,
1864
- posts: [
1865
- {
1866
- id: 2,
1867
- authorId: 1,
1868
- content: '2MESSAGE',
1869
- },
1870
- {
1871
- id: 3,
1872
- authorId: 1,
1873
- content: '3MESSAGE',
1874
- },
1875
- ],
1876
- },
1877
- {
1878
- id: 2,
1879
- posts: [],
1880
- },
1881
- {
1882
- id: 5,
1883
- posts: [
1884
- {
1885
- id: 5,
1886
- authorId: 5,
1887
- content: '2MESSAGE',
1888
- },
1889
- ],
1890
- },
1891
- ],
1892
- },
1893
- });
1894
- });
1895
-
1896
- it('Relations filters', async () => {
1897
- const res = await ctx.gql.queryGql(/* GraphQL */ `
1898
- {
1899
- users {
1900
- id
1901
- posts(where: { content: { like: "2%" } }) {
1902
- id
1903
- authorId
1904
- content
1905
- }
1906
- }
1907
- }
1908
- `);
1909
-
1910
- expect(res).toStrictEqual({
1911
- data: {
1912
- users: [
1913
- {
1914
- id: 1,
1915
- posts: [
1916
- {
1917
- id: 2,
1918
- authorId: 1,
1919
- content: '2MESSAGE',
1920
- },
1921
- ],
1922
- },
1923
- {
1924
- id: 2,
1925
- posts: [],
1926
- },
1927
- {
1928
- id: 5,
1929
- posts: [
1930
- {
1931
- id: 5,
1932
- authorId: 5,
1933
- content: '2MESSAGE',
1934
- },
1935
- ],
1936
- },
1937
- ],
1938
- },
1939
- });
1940
- });
1941
- });
1942
-
1943
- describe.sequential('Returned data tests', () => {
1944
- it('Schema', () => {
1945
- expect(ctx.schema instanceof GraphQLSchema).toBe(true);
1946
- });
1947
-
1948
- it('Entities', () => {
1949
- ctx.entities.mutations;
1950
- const schema = z
1951
- .object({
1952
- queries: z
1953
- .object({
1954
- users: z
1955
- .object({
1956
- args: z
1957
- .object({
1958
- orderBy: z
1959
- .object({
1960
- type: z.instanceof(GraphQLInputObjectType),
1961
- })
1962
- .strict(),
1963
- offset: z
1964
- .object({
1965
- type: z.instanceof(GraphQLScalarType),
1966
- })
1967
- .strict(),
1968
- limit: z
1969
- .object({
1970
- type: z.instanceof(GraphQLScalarType),
1971
- })
1972
- .strict(),
1973
- where: z
1974
- .object({
1975
- type: z.instanceof(GraphQLInputObjectType),
1976
- })
1977
- .strict(),
1978
- })
1979
- .strict(),
1980
- resolve: z.function(),
1981
- type: z.instanceof(GraphQLNonNull),
1982
- })
1983
- .strict(),
1984
- usersSingle: z
1985
- .object({
1986
- args: z
1987
- .object({
1988
- orderBy: z
1989
- .object({
1990
- type: z.instanceof(GraphQLInputObjectType),
1991
- })
1992
- .strict(),
1993
- offset: z
1994
- .object({
1995
- type: z.instanceof(GraphQLScalarType),
1996
- })
1997
- .strict(),
1998
- where: z
1999
- .object({
2000
- type: z.instanceof(GraphQLInputObjectType),
2001
- })
2002
- .strict(),
2003
- })
2004
- .strict(),
2005
- resolve: z.function(),
2006
- type: z.instanceof(GraphQLObjectType),
2007
- })
2008
- .strict(),
2009
- posts: z
2010
- .object({
2011
- args: z
2012
- .object({
2013
- orderBy: z
2014
- .object({
2015
- type: z.instanceof(GraphQLInputObjectType),
2016
- })
2017
- .strict(),
2018
- offset: z
2019
- .object({
2020
- type: z.instanceof(GraphQLScalarType),
2021
- })
2022
- .strict(),
2023
- limit: z
2024
- .object({
2025
- type: z.instanceof(GraphQLScalarType),
2026
- })
2027
- .strict(),
2028
- where: z
2029
- .object({
2030
- type: z.instanceof(GraphQLInputObjectType),
2031
- })
2032
- .strict(),
2033
- })
2034
- .strict(),
2035
- resolve: z.function(),
2036
- type: z.instanceof(GraphQLNonNull),
2037
- })
2038
- .strict(),
2039
- postsSingle: z
2040
- .object({
2041
- args: z
2042
- .object({
2043
- orderBy: z
2044
- .object({
2045
- type: z.instanceof(GraphQLInputObjectType),
2046
- })
2047
- .strict(),
2048
- offset: z
2049
- .object({
2050
- type: z.instanceof(GraphQLScalarType),
2051
- })
2052
- .strict(),
2053
- where: z
2054
- .object({
2055
- type: z.instanceof(GraphQLInputObjectType),
2056
- })
2057
- .strict(),
2058
- })
2059
- .strict(),
2060
- resolve: z.function(),
2061
- type: z.instanceof(GraphQLObjectType),
2062
- })
2063
- .strict(),
2064
- customers: z
2065
- .object({
2066
- args: z
2067
- .object({
2068
- orderBy: z
2069
- .object({
2070
- type: z.instanceof(GraphQLInputObjectType),
2071
- })
2072
- .strict(),
2073
- offset: z
2074
- .object({
2075
- type: z.instanceof(GraphQLScalarType),
2076
- })
2077
- .strict(),
2078
- limit: z
2079
- .object({
2080
- type: z.instanceof(GraphQLScalarType),
2081
- })
2082
- .strict(),
2083
- where: z
2084
- .object({
2085
- type: z.instanceof(GraphQLInputObjectType),
2086
- })
2087
- .strict(),
2088
- })
2089
- .strict(),
2090
- resolve: z.function(),
2091
- type: z.instanceof(GraphQLNonNull),
2092
- })
2093
- .strict(),
2094
- customersSingle: z
2095
- .object({
2096
- args: z
2097
- .object({
2098
- orderBy: z
2099
- .object({
2100
- type: z.instanceof(GraphQLInputObjectType),
2101
- })
2102
- .strict(),
2103
- offset: z
2104
- .object({
2105
- type: z.instanceof(GraphQLScalarType),
2106
- })
2107
- .strict(),
2108
- where: z
2109
- .object({
2110
- type: z.instanceof(GraphQLInputObjectType),
2111
- })
2112
- .strict(),
2113
- })
2114
- .strict(),
2115
- resolve: z.function(),
2116
- type: z.instanceof(GraphQLObjectType),
2117
- })
2118
- .strict(),
2119
- })
2120
- .strict(),
2121
- mutations: z
2122
- .object({
2123
- insertIntoUsers: z
2124
- .object({
2125
- args: z
2126
- .object({
2127
- values: z
2128
- .object({
2129
- type: z.instanceof(GraphQLNonNull),
2130
- })
2131
- .strict(),
2132
- })
2133
- .strict(),
2134
- resolve: z.function(),
2135
- type: z.instanceof(GraphQLNonNull),
2136
- })
2137
- .strict(),
2138
- insertIntoUsersSingle: z
2139
- .object({
2140
- args: z
2141
- .object({
2142
- values: z
2143
- .object({
2144
- type: z.instanceof(GraphQLNonNull),
2145
- })
2146
- .strict(),
2147
- })
2148
- .strict(),
2149
- resolve: z.function(),
2150
- type: z.instanceof(GraphQLObjectType),
2151
- })
2152
- .strict(),
2153
- updateUsers: z
2154
- .object({
2155
- args: z
2156
- .object({
2157
- set: z
2158
- .object({
2159
- type: z.instanceof(GraphQLNonNull),
2160
- })
2161
- .strict(),
2162
- where: z
2163
- .object({
2164
- type: z.instanceof(GraphQLInputObjectType),
2165
- })
2166
- .strict(),
2167
- })
2168
- .strict(),
2169
- resolve: z.function(),
2170
- type: z.instanceof(GraphQLNonNull),
2171
- })
2172
- .strict(),
2173
- deleteFromUsers: z
2174
- .object({
2175
- args: z
2176
- .object({
2177
- where: z
2178
- .object({
2179
- type: z.instanceof(GraphQLInputObjectType),
2180
- })
2181
- .strict(),
2182
- })
2183
- .strict(),
2184
- resolve: z.function(),
2185
- type: z.instanceof(GraphQLNonNull),
2186
- })
2187
- .strict(),
2188
- insertIntoPosts: z
2189
- .object({
2190
- args: z
2191
- .object({
2192
- values: z
2193
- .object({
2194
- type: z.instanceof(GraphQLNonNull),
2195
- })
2196
- .strict(),
2197
- })
2198
- .strict(),
2199
- resolve: z.function(),
2200
- type: z.instanceof(GraphQLNonNull),
2201
- })
2202
- .strict(),
2203
- insertIntoPostsSingle: z
2204
- .object({
2205
- args: z
2206
- .object({
2207
- values: z
2208
- .object({
2209
- type: z.instanceof(GraphQLNonNull),
2210
- })
2211
- .strict(),
2212
- })
2213
- .strict(),
2214
- resolve: z.function(),
2215
- type: z.instanceof(GraphQLObjectType),
2216
- })
2217
- .strict(),
2218
- updatePosts: z
2219
- .object({
2220
- args: z
2221
- .object({
2222
- set: z
2223
- .object({
2224
- type: z.instanceof(GraphQLNonNull),
2225
- })
2226
- .strict(),
2227
- where: z
2228
- .object({
2229
- type: z.instanceof(GraphQLInputObjectType),
2230
- })
2231
- .strict(),
2232
- })
2233
- .strict(),
2234
- resolve: z.function(),
2235
- type: z.instanceof(GraphQLNonNull),
2236
- })
2237
- .strict(),
2238
- deleteFromPosts: z
2239
- .object({
2240
- args: z
2241
- .object({
2242
- where: z
2243
- .object({
2244
- type: z.instanceof(GraphQLInputObjectType),
2245
- })
2246
- .strict(),
2247
- })
2248
- .strict(),
2249
- resolve: z.function(),
2250
- type: z.instanceof(GraphQLNonNull),
2251
- })
2252
- .strict(),
2253
- insertIntoCustomers: z
2254
- .object({
2255
- args: z
2256
- .object({
2257
- values: z
2258
- .object({
2259
- type: z.instanceof(GraphQLNonNull),
2260
- })
2261
- .strict(),
2262
- })
2263
- .strict(),
2264
- resolve: z.function(),
2265
- type: z.instanceof(GraphQLNonNull),
2266
- })
2267
- .strict(),
2268
- insertIntoCustomersSingle: z
2269
- .object({
2270
- args: z
2271
- .object({
2272
- values: z
2273
- .object({
2274
- type: z.instanceof(GraphQLNonNull),
2275
- })
2276
- .strict(),
2277
- })
2278
- .strict(),
2279
- resolve: z.function(),
2280
- type: z.instanceof(GraphQLObjectType),
2281
- })
2282
- .strict(),
2283
- updateCustomers: z
2284
- .object({
2285
- args: z
2286
- .object({
2287
- set: z
2288
- .object({
2289
- type: z.instanceof(GraphQLNonNull),
2290
- })
2291
- .strict(),
2292
- where: z
2293
- .object({
2294
- type: z.instanceof(GraphQLInputObjectType),
2295
- })
2296
- .strict(),
2297
- })
2298
- .strict(),
2299
- resolve: z.function(),
2300
- type: z.instanceof(GraphQLNonNull),
2301
- })
2302
- .strict(),
2303
- deleteFromCustomers: z
2304
- .object({
2305
- args: z
2306
- .object({
2307
- where: z
2308
- .object({
2309
- type: z.instanceof(GraphQLInputObjectType),
2310
- })
2311
- .strict(),
2312
- })
2313
- .strict(),
2314
- resolve: z.function(),
2315
- type: z.instanceof(GraphQLNonNull),
2316
- })
2317
- .strict(),
2318
- })
2319
- .strict(),
2320
- types: z
2321
- .object({
2322
- UsersItem: z.instanceof(GraphQLObjectType),
2323
- UsersSelectItem: z.instanceof(GraphQLObjectType),
2324
- PostsItem: z.instanceof(GraphQLObjectType),
2325
- PostsSelectItem: z.instanceof(GraphQLObjectType),
2326
- CustomersItem: z.instanceof(GraphQLObjectType),
2327
- CustomersSelectItem: z.instanceof(GraphQLObjectType),
2328
- })
2329
- .strict(),
2330
- inputs: z
2331
- .object({
2332
- UsersFilters: z.instanceof(GraphQLInputObjectType),
2333
- UsersOrderBy: z.instanceof(GraphQLInputObjectType),
2334
- UsersInsertInput: z.instanceof(GraphQLInputObjectType),
2335
- UsersUpdateInput: z.instanceof(GraphQLInputObjectType),
2336
- PostsFilters: z.instanceof(GraphQLInputObjectType),
2337
- PostsOrderBy: z.instanceof(GraphQLInputObjectType),
2338
- PostsInsertInput: z.instanceof(GraphQLInputObjectType),
2339
- PostsUpdateInput: z.instanceof(GraphQLInputObjectType),
2340
- CustomersFilters: z.instanceof(GraphQLInputObjectType),
2341
- CustomersOrderBy: z.instanceof(GraphQLInputObjectType),
2342
- CustomersInsertInput: z.instanceof(GraphQLInputObjectType),
2343
- CustomersUpdateInput: z.instanceof(GraphQLInputObjectType),
2344
- })
2345
- .strict(),
2346
- })
2347
- .strict();
2348
-
2349
- const parseRes = schema.safeParse(ctx.entities);
2350
-
2351
- if (!parseRes.success) console.log(parseRes.error);
2352
-
2353
- expect(parseRes.success).toEqual(true);
2354
- });
2355
- });
2356
-
2357
- describe.sequential('Type tests', () => {
2358
- it('Schema', () => {
2359
- expectTypeOf(ctx.schema).toEqualTypeOf<GraphQLSchema>();
2360
- });
2361
-
2362
- it('Queries', () => {
2363
- expectTypeOf(ctx.entities.queries).toEqualTypeOf<
2364
- {
2365
- readonly customers: {
2366
- type: GraphQLNonNull<GraphQLList<GraphQLNonNull<GraphQLObjectType>>>;
2367
- args: {
2368
- orderBy: { type: GraphQLInputObjectType };
2369
- offset: { type: GraphQLScalarType<number, number> };
2370
- limit: { type: GraphQLScalarType<number, number> };
2371
- where: { type: GraphQLInputObjectType };
2372
- };
2373
- resolve: SelectResolver<
2374
- typeof schema.Customers,
2375
- ExtractTables<typeof schema>,
2376
- typeof schema.customersRelations extends Relations<any, infer RelConf> ? RelConf : never
2377
- >;
2378
- };
2379
- readonly posts: {
2380
- type: GraphQLNonNull<GraphQLList<GraphQLNonNull<GraphQLObjectType>>>;
2381
- args: {
2382
- orderBy: { type: GraphQLInputObjectType };
2383
- offset: { type: GraphQLScalarType<number, number> };
2384
- limit: { type: GraphQLScalarType<number, number> };
2385
- where: { type: GraphQLInputObjectType };
2386
- };
2387
- resolve: SelectResolver<
2388
- typeof schema.Posts,
2389
- ExtractTables<typeof schema>,
2390
- typeof schema.postsRelations extends Relations<any, infer RelConf> ? RelConf : never
2391
- >;
2392
- };
2393
- readonly users: {
2394
- type: GraphQLNonNull<GraphQLList<GraphQLNonNull<GraphQLObjectType>>>;
2395
- args: {
2396
- orderBy: { type: GraphQLInputObjectType };
2397
- offset: { type: GraphQLScalarType<number, number> };
2398
- limit: { type: GraphQLScalarType<number, number> };
2399
- where: { type: GraphQLInputObjectType };
2400
- };
2401
- resolve: SelectResolver<
2402
- typeof schema.Users,
2403
- ExtractTables<typeof schema>,
2404
- typeof schema.usersRelations extends Relations<any, infer RelConf> ? RelConf : never
2405
- >;
2406
- };
2407
- } & {
2408
- readonly customersSingle: {
2409
- type: GraphQLObjectType;
2410
- args: {
2411
- orderBy: { type: GraphQLInputObjectType };
2412
- offset: { type: GraphQLScalarType<number, number> };
2413
- where: { type: GraphQLInputObjectType };
2414
- };
2415
- resolve: SelectSingleResolver<
2416
- typeof schema.Customers,
2417
- ExtractTables<typeof schema>,
2418
- typeof schema.customersRelations extends Relations<any, infer RelConf> ? RelConf : never
2419
- >;
2420
- };
2421
- readonly postsSingle: {
2422
- type: GraphQLObjectType;
2423
- args: {
2424
- orderBy: { type: GraphQLInputObjectType };
2425
- offset: { type: GraphQLScalarType<number, number> };
2426
- where: { type: GraphQLInputObjectType };
2427
- };
2428
- resolve: SelectSingleResolver<
2429
- typeof schema.Posts,
2430
- ExtractTables<typeof schema>,
2431
- typeof schema.postsRelations extends Relations<any, infer RelConf> ? RelConf : never
2432
- >;
2433
- };
2434
- readonly usersSingle: {
2435
- type: GraphQLObjectType;
2436
- args: {
2437
- orderBy: { type: GraphQLInputObjectType };
2438
- offset: { type: GraphQLScalarType<number, number> };
2439
- where: { type: GraphQLInputObjectType };
2440
- };
2441
- resolve: SelectSingleResolver<
2442
- typeof schema.Users,
2443
- ExtractTables<typeof schema>,
2444
- typeof schema.usersRelations extends Relations<any, infer RelConf> ? RelConf : never
2445
- >;
2446
- };
2447
- }
2448
- >();
2449
- });
2450
-
2451
- it('Mutations', () => {
2452
- expectTypeOf(ctx.entities.mutations).toEqualTypeOf<
2453
- {
2454
- readonly insertIntoCustomers: {
2455
- type: GraphQLNonNull<GraphQLList<GraphQLNonNull<GraphQLObjectType>>>;
2456
- args: {
2457
- values: {
2458
- type: GraphQLNonNull<GraphQLList<GraphQLNonNull<GraphQLInputObjectType>>>;
2459
- };
2460
- };
2461
- resolve: InsertArrResolver<typeof schema.Customers, false>;
2462
- };
2463
- readonly insertIntoPosts: {
2464
- type: GraphQLNonNull<GraphQLList<GraphQLNonNull<GraphQLObjectType>>>;
2465
- args: {
2466
- values: {
2467
- type: GraphQLNonNull<GraphQLList<GraphQLNonNull<GraphQLInputObjectType>>>;
2468
- };
2469
- };
2470
- resolve: InsertArrResolver<typeof schema.Posts, false>;
2471
- };
2472
- readonly insertIntoUsers: {
2473
- type: GraphQLNonNull<GraphQLList<GraphQLNonNull<GraphQLObjectType>>>;
2474
- args: {
2475
- values: {
2476
- type: GraphQLNonNull<GraphQLList<GraphQLNonNull<GraphQLInputObjectType>>>;
2477
- };
2478
- };
2479
- resolve: InsertArrResolver<typeof schema.Users, false>;
2480
- };
2481
- } & {
2482
- readonly insertIntoCustomersSingle: {
2483
- type: GraphQLObjectType;
2484
- args: {
2485
- values: {
2486
- type: GraphQLNonNull<GraphQLInputObjectType>;
2487
- };
2488
- };
2489
- resolve: InsertResolver<typeof schema.Customers, false>;
2490
- };
2491
- readonly insertIntoPostsSingle: {
2492
- type: GraphQLObjectType;
2493
- args: {
2494
- values: {
2495
- type: GraphQLNonNull<GraphQLInputObjectType>;
2496
- };
2497
- };
2498
- resolve: InsertResolver<typeof schema.Posts, false>;
2499
- };
2500
- readonly insertIntoUsersSingle: {
2501
- type: GraphQLObjectType;
2502
- args: {
2503
- values: {
2504
- type: GraphQLNonNull<GraphQLInputObjectType>;
2505
- };
2506
- };
2507
- resolve: InsertResolver<typeof schema.Users, false>;
2508
- };
2509
- } & {
2510
- readonly updateCustomers: {
2511
- type: GraphQLNonNull<GraphQLList<GraphQLNonNull<GraphQLObjectType>>>;
2512
- args: {
2513
- set: {
2514
- type: GraphQLNonNull<GraphQLInputObjectType>;
2515
- };
2516
- where: { type: GraphQLInputObjectType };
2517
- };
2518
- resolve: UpdateResolver<typeof schema.Customers, false>;
2519
- };
2520
- readonly updatePosts: {
2521
- type: GraphQLNonNull<GraphQLList<GraphQLNonNull<GraphQLObjectType>>>;
2522
- args: {
2523
- set: {
2524
- type: GraphQLNonNull<GraphQLInputObjectType>;
2525
- };
2526
- where: { type: GraphQLInputObjectType };
2527
- };
2528
- resolve: UpdateResolver<typeof schema.Posts, false>;
2529
- };
2530
- readonly updateUsers: {
2531
- type: GraphQLNonNull<GraphQLList<GraphQLNonNull<GraphQLObjectType>>>;
2532
- args: {
2533
- set: {
2534
- type: GraphQLNonNull<GraphQLInputObjectType>;
2535
- };
2536
- where: { type: GraphQLInputObjectType };
2537
- };
2538
- resolve: UpdateResolver<typeof schema.Users, false>;
2539
- };
2540
- } & {
2541
- readonly deleteFromCustomers: {
2542
- type: GraphQLNonNull<GraphQLList<GraphQLNonNull<GraphQLObjectType>>>;
2543
- args: {
2544
- where: { type: GraphQLInputObjectType };
2545
- };
2546
- resolve: DeleteResolver<typeof schema.Customers, false>;
2547
- };
2548
- readonly deleteFromPosts: {
2549
- type: GraphQLNonNull<GraphQLList<GraphQLNonNull<GraphQLObjectType>>>;
2550
- args: {
2551
- where: { type: GraphQLInputObjectType };
2552
- };
2553
- resolve: DeleteResolver<typeof schema.Posts, false>;
2554
- };
2555
- readonly deleteFromUsers: {
2556
- type: GraphQLNonNull<GraphQLList<GraphQLNonNull<GraphQLObjectType>>>;
2557
- args: {
2558
- where: { type: GraphQLInputObjectType };
2559
- };
2560
- resolve: DeleteResolver<typeof schema.Users, false>;
2561
- };
2562
- }
2563
- >();
2564
- });
2565
-
2566
- it('Types', () => {
2567
- expectTypeOf(ctx.entities.types).toEqualTypeOf<
2568
- {
2569
- readonly CustomersItem: GraphQLObjectType;
2570
- readonly PostsItem: GraphQLObjectType;
2571
- readonly UsersItem: GraphQLObjectType;
2572
- } & {
2573
- readonly CustomersSelectItem: GraphQLObjectType;
2574
- readonly PostsSelectItem: GraphQLObjectType;
2575
- readonly UsersSelectItem: GraphQLObjectType;
2576
- }
2577
- >();
2578
- });
2579
-
2580
- it('Inputs', () => {
2581
- expectTypeOf(ctx.entities.inputs).toEqualTypeOf<
2582
- {
2583
- readonly UsersFilters: GraphQLInputObjectType;
2584
- readonly CustomersFilters: GraphQLInputObjectType;
2585
- readonly PostsFilters: GraphQLInputObjectType;
2586
- } & {
2587
- readonly UsersOrderBy: GraphQLInputObjectType;
2588
- readonly CustomersOrderBy: GraphQLInputObjectType;
2589
- readonly PostsOrderBy: GraphQLInputObjectType;
2590
- } & {
2591
- readonly UsersInsertInput: GraphQLInputObjectType;
2592
- readonly CustomersInsertInput: GraphQLInputObjectType;
2593
- readonly PostsInsertInput: GraphQLInputObjectType;
2594
- } & {
2595
- readonly UsersUpdateInput: GraphQLInputObjectType;
2596
- readonly CustomersUpdateInput: GraphQLInputObjectType;
2597
- readonly PostsUpdateInput: GraphQLInputObjectType;
2598
- }
2599
- >();
2600
- });
2601
- });
2602
-
2603
- describe.sequential('__typename only tests', () => {
2604
- it(`Select single`, async () => {
2605
- const res = await ctx.gql.queryGql(/* GraphQL */ `
2606
- {
2607
- usersSingle {
2608
- __typename
2609
- }
2610
-
2611
- postsSingle {
2612
- __typename
2613
- }
2614
- }
2615
- `);
2616
-
2617
- expect(res).toStrictEqual({
2618
- data: {
2619
- usersSingle: {
2620
- __typename: 'UsersSelectItem',
2621
- },
2622
- postsSingle: {
2623
- __typename: 'PostsSelectItem',
2624
- },
2625
- },
2626
- });
2627
- });
2628
-
2629
- it(`Select array`, async () => {
2630
- const res = await ctx.gql.queryGql(/* GraphQL */ `
2631
- {
2632
- users {
2633
- __typename
2634
- }
2635
-
2636
- posts {
2637
- __typename
2638
- }
2639
- }
2640
- `);
2641
-
2642
- expect(res).toStrictEqual({
2643
- data: {
2644
- users: [
2645
- {
2646
- __typename: 'UsersSelectItem',
2647
- },
2648
- {
2649
- __typename: 'UsersSelectItem',
2650
- },
2651
- {
2652
- __typename: 'UsersSelectItem',
2653
- },
2654
- ],
2655
- posts: [
2656
- {
2657
- __typename: 'PostsSelectItem',
2658
- },
2659
- {
2660
- __typename: 'PostsSelectItem',
2661
- },
2662
- {
2663
- __typename: 'PostsSelectItem',
2664
- },
2665
- {
2666
- __typename: 'PostsSelectItem',
2667
- },
2668
- {
2669
- __typename: 'PostsSelectItem',
2670
- },
2671
- {
2672
- __typename: 'PostsSelectItem',
2673
- },
2674
- ],
2675
- },
2676
- });
2677
- });
2678
-
2679
- it(`Select single with relations`, async () => {
2680
- const res = await ctx.gql.queryGql(/* GraphQL */ `
2681
- {
2682
- usersSingle {
2683
- __typename
2684
- posts {
2685
- __typename
2686
- }
2687
- }
2688
-
2689
- postsSingle {
2690
- __typename
2691
- author {
2692
- __typename
2693
- }
2694
- }
2695
- }
2696
- `);
2697
-
2698
- expect(res).toStrictEqual({
2699
- data: {
2700
- usersSingle: {
2701
- __typename: 'UsersSelectItem',
2702
- posts: [
2703
- {
2704
- __typename: 'UsersPostsRelation',
2705
- },
2706
- {
2707
- __typename: 'UsersPostsRelation',
2708
- },
2709
- {
2710
- __typename: 'UsersPostsRelation',
2711
- },
2712
-
2713
- {
2714
- __typename: 'UsersPostsRelation',
2715
- },
2716
- ],
2717
- },
2718
- postsSingle: {
2719
- __typename: 'PostsSelectItem',
2720
- author: {
2721
- __typename: 'PostsAuthorRelation',
2722
- },
2723
- },
2724
- },
2725
- });
2726
- });
2727
-
2728
- it(`Select array with relations`, async () => {
2729
- const res = await ctx.gql.queryGql(/* GraphQL */ `
2730
- {
2731
- users {
2732
- __typename
2733
- posts {
2734
- __typename
2735
- }
2736
- }
2737
- posts {
2738
- __typename
2739
- author {
2740
- __typename
2741
- }
2742
- }
2743
- }
2744
- `);
2745
-
2746
- expect(res).toStrictEqual({
2747
- data: {
2748
- users: [
2749
- {
2750
- __typename: 'UsersSelectItem',
2751
- posts: [
2752
- {
2753
- __typename: 'UsersPostsRelation',
2754
- },
2755
- {
2756
- __typename: 'UsersPostsRelation',
2757
- },
2758
- {
2759
- __typename: 'UsersPostsRelation',
2760
- },
2761
- {
2762
- __typename: 'UsersPostsRelation',
2763
- },
2764
- ],
2765
- },
2766
- {
2767
- __typename: 'UsersSelectItem',
2768
- posts: [],
2769
- },
2770
- {
2771
- __typename: 'UsersSelectItem',
2772
- posts: [
2773
- {
2774
- __typename: 'UsersPostsRelation',
2775
- },
2776
- {
2777
- __typename: 'UsersPostsRelation',
2778
- },
2779
- ],
2780
- },
2781
- ],
2782
- posts: [
2783
- {
2784
- __typename: 'PostsSelectItem',
2785
- author: {
2786
- __typename: 'PostsAuthorRelation',
2787
- },
2788
- },
2789
- {
2790
- __typename: 'PostsSelectItem',
2791
- author: {
2792
- __typename: 'PostsAuthorRelation',
2793
- },
2794
- },
2795
- {
2796
- __typename: 'PostsSelectItem',
2797
- author: {
2798
- __typename: 'PostsAuthorRelation',
2799
- },
2800
- },
2801
- {
2802
- __typename: 'PostsSelectItem',
2803
- author: {
2804
- __typename: 'PostsAuthorRelation',
2805
- },
2806
- },
2807
- {
2808
- __typename: 'PostsSelectItem',
2809
- author: {
2810
- __typename: 'PostsAuthorRelation',
2811
- },
2812
- },
2813
- {
2814
- __typename: 'PostsSelectItem',
2815
- author: {
2816
- __typename: 'PostsAuthorRelation',
2817
- },
2818
- },
2819
- ],
2820
- },
2821
- });
2822
- });
2823
-
2824
- it(`Insert single`, async () => {
2825
- const res = await ctx.gql.queryGql(/* GraphQL */ `
2826
- mutation {
2827
- insertIntoUsersSingle(
2828
- values: {
2829
- id: 3
2830
- name: "ThirdUser"
2831
- email: "userThree@notmail.com"
2832
- textJson: "{ \\"field\\": \\"value\\" }"
2833
- blobBigInt: "10"
2834
- numeric: "250.2"
2835
- createdAt: "2024-04-02T06:44:41.785Z"
2836
- createdAtMs: "2024-04-02T06:44:41.785Z"
2837
- real: 13.5
2838
- text: "sometext"
2839
- role: admin
2840
- isConfirmed: true
2841
- }
2842
- ) {
2843
- __typename
2844
- }
2845
- }
2846
- `);
2847
-
2848
- expect(res).toStrictEqual({
2849
- data: {
2850
- insertIntoUsersSingle: {
2851
- __typename: 'UsersItem',
2852
- },
2853
- },
2854
- });
2855
- });
2856
-
2857
- it(`Insert array`, async () => {
2858
- const res = await ctx.gql.queryGql(/* GraphQL */ `
2859
- mutation {
2860
- insertIntoUsers(
2861
- values: [
2862
- {
2863
- id: 3
2864
- name: "ThirdUser"
2865
- email: "userThree@notmail.com"
2866
- textJson: "{ \\"field\\": \\"value\\" }"
2867
- blobBigInt: "10"
2868
- numeric: "250.2"
2869
- createdAt: "2024-04-02T06:44:41.785Z"
2870
- createdAtMs: "2024-04-02T06:44:41.785Z"
2871
- real: 13.5
2872
- text: "sometext"
2873
- role: admin
2874
- isConfirmed: true
2875
- }
2876
- {
2877
- id: 4
2878
- name: "FourthUser"
2879
- email: "userFour@notmail.com"
2880
- textJson: "{ \\"field\\": \\"value\\" }"
2881
- blobBigInt: "10"
2882
- numeric: "250.2"
2883
- createdAt: "2024-04-02T06:44:41.785Z"
2884
- createdAtMs: "2024-04-02T06:44:41.785Z"
2885
- real: 13.5
2886
- text: "sometext"
2887
- role: user
2888
- isConfirmed: false
2889
- }
2890
- ]
2891
- ) {
2892
- __typename
2893
- }
2894
- }
2895
- `);
2896
-
2897
- expect(res).toStrictEqual({
2898
- data: {
2899
- insertIntoUsers: [
2900
- {
2901
- __typename: 'UsersItem',
2902
- },
2903
- {
2904
- __typename: 'UsersItem',
2905
- },
2906
- ],
2907
- },
2908
- });
2909
- });
2910
-
2911
- it(`Update`, async () => {
2912
- const res = await ctx.gql.queryGql(/* GraphQL */ `
2913
- mutation {
2914
- updateCustomers(set: { isConfirmed: true, address: "Edited" }) {
2915
- __typename
2916
- }
2917
- }
2918
- `);
2919
-
2920
- expect(res).toStrictEqual({
2921
- data: {
2922
- updateCustomers: [
2923
- {
2924
- __typename: 'CustomersItem',
2925
- },
2926
- {
2927
- __typename: 'CustomersItem',
2928
- },
2929
- ],
2930
- },
2931
- });
2932
- });
2933
-
2934
- it(`Delete`, async () => {
2935
- const res = await ctx.gql.queryGql(/* GraphQL */ `
2936
- mutation {
2937
- deleteFromCustomers {
2938
- __typename
2939
- }
2940
- }
2941
- `);
2942
-
2943
- expect(res).toStrictEqual({
2944
- data: {
2945
- deleteFromCustomers: [
2946
- {
2947
- __typename: 'CustomersItem',
2948
- },
2949
- {
2950
- __typename: 'CustomersItem',
2951
- },
2952
- ],
2953
- },
2954
- });
2955
- });
2956
- });
2957
-
2958
- describe.sequential('__typename with data tests', async () => {
2959
- it(`Select single`, async () => {
2960
- const res = await ctx.gql.queryGql(/* GraphQL */ `
2961
- {
2962
- usersSingle {
2963
- id
2964
- name
2965
- email
2966
- textJson
2967
- blobBigInt
2968
- numeric
2969
- createdAt
2970
- createdAtMs
2971
- real
2972
- text
2973
- role
2974
- isConfirmed
2975
- __typename
2976
- }
2977
-
2978
- postsSingle {
2979
- id
2980
- authorId
2981
- content
2982
- __typename
2983
- }
2984
- }
2985
- `);
2986
-
2987
- expect(res).toStrictEqual({
2988
- data: {
2989
- usersSingle: {
2990
- id: 1,
2991
- name: 'FirstUser',
2992
- email: 'userOne@notmail.com',
2993
- textJson: '{"field":"value"}',
2994
- blobBigInt: '10',
2995
- numeric: '250.2',
2996
- createdAt: '2024-04-02T06:44:41.000Z',
2997
- createdAtMs: '2024-04-02T06:44:41.785Z',
2998
- real: 13.5,
2999
- text: 'sometext',
3000
- role: 'admin',
3001
- isConfirmed: true,
3002
- __typename: 'UsersSelectItem',
3003
- },
3004
- postsSingle: {
3005
- id: 1,
3006
- authorId: 1,
3007
- content: '1MESSAGE',
3008
- __typename: 'PostsSelectItem',
3009
- },
3010
- },
3011
- });
3012
- });
3013
-
3014
- it(`Select array`, async () => {
3015
- const res = await ctx.gql.queryGql(/* GraphQL */ `
3016
- {
3017
- users {
3018
- id
3019
- name
3020
- email
3021
- textJson
3022
- blobBigInt
3023
- numeric
3024
- createdAt
3025
- createdAtMs
3026
- real
3027
- text
3028
- role
3029
- isConfirmed
3030
- __typename
3031
- }
3032
-
3033
- posts {
3034
- id
3035
- authorId
3036
- content
3037
- __typename
3038
- }
3039
- }
3040
- `);
3041
-
3042
- expect(res).toStrictEqual({
3043
- data: {
3044
- users: [
3045
- {
3046
- id: 1,
3047
- name: 'FirstUser',
3048
- email: 'userOne@notmail.com',
3049
- textJson: '{"field":"value"}',
3050
- blobBigInt: '10',
3051
- numeric: '250.2',
3052
- createdAt: '2024-04-02T06:44:41.000Z',
3053
- createdAtMs: '2024-04-02T06:44:41.785Z',
3054
- real: 13.5,
3055
- text: 'sometext',
3056
- role: 'admin',
3057
- isConfirmed: true,
3058
- __typename: 'UsersSelectItem',
3059
- },
3060
- {
3061
- id: 2,
3062
- name: 'SecondUser',
3063
- email: null,
3064
- blobBigInt: null,
3065
- textJson: null,
3066
- createdAt: '2024-04-02T06:44:41.000Z',
3067
- createdAtMs: null,
3068
- numeric: null,
3069
- real: null,
3070
- text: null,
3071
- role: 'user',
3072
- isConfirmed: null,
3073
- __typename: 'UsersSelectItem',
3074
- },
3075
- {
3076
- id: 5,
3077
- name: 'FifthUser',
3078
- email: null,
3079
- createdAt: '2024-04-02T06:44:41.000Z',
3080
- role: 'user',
3081
- blobBigInt: null,
3082
- textJson: null,
3083
- createdAtMs: null,
3084
- numeric: null,
3085
- real: null,
3086
- text: null,
3087
- isConfirmed: null,
3088
- __typename: 'UsersSelectItem',
3089
- },
3090
- ],
3091
- posts: [
3092
- {
3093
- id: 1,
3094
- authorId: 1,
3095
- content: '1MESSAGE',
3096
- __typename: 'PostsSelectItem',
3097
- },
3098
- {
3099
- id: 2,
3100
- authorId: 1,
3101
- content: '2MESSAGE',
3102
- __typename: 'PostsSelectItem',
3103
- },
3104
- {
3105
- id: 3,
3106
- authorId: 1,
3107
- content: '3MESSAGE',
3108
- __typename: 'PostsSelectItem',
3109
- },
3110
- {
3111
- id: 4,
3112
- authorId: 5,
3113
- content: '1MESSAGE',
3114
- __typename: 'PostsSelectItem',
3115
- },
3116
- {
3117
- id: 5,
3118
- authorId: 5,
3119
- content: '2MESSAGE',
3120
- __typename: 'PostsSelectItem',
3121
- },
3122
- {
3123
- id: 6,
3124
- authorId: 1,
3125
- content: '4MESSAGE',
3126
- __typename: 'PostsSelectItem',
3127
- },
3128
- ],
3129
- },
3130
- });
3131
- });
3132
-
3133
- it(`Select single with relations`, async () => {
3134
- const res = await ctx.gql.queryGql(/* GraphQL */ `
3135
- {
3136
- usersSingle {
3137
- id
3138
- name
3139
- email
3140
- textJson
3141
- blobBigInt
3142
- numeric
3143
- createdAt
3144
- createdAtMs
3145
- real
3146
- text
3147
- role
3148
- isConfirmed
3149
- __typename
3150
- posts {
3151
- id
3152
- authorId
3153
- content
3154
- __typename
3155
- }
3156
- }
3157
-
3158
- postsSingle {
3159
- id
3160
- authorId
3161
- content
3162
- __typename
3163
- author {
3164
- id
3165
- name
3166
- email
3167
- textJson
3168
- numeric
3169
- createdAt
3170
- createdAtMs
3171
- real
3172
- text
3173
- role
3174
- isConfirmed
3175
- __typename
3176
- }
3177
- }
3178
- }
3179
- `);
3180
-
3181
- expect(res).toStrictEqual({
3182
- data: {
3183
- usersSingle: {
3184
- id: 1,
3185
- name: 'FirstUser',
3186
- email: 'userOne@notmail.com',
3187
- textJson: '{"field":"value"}',
3188
- blobBigInt: '10',
3189
- numeric: '250.2',
3190
- createdAt: '2024-04-02T06:44:41.000Z',
3191
- createdAtMs: '2024-04-02T06:44:41.785Z',
3192
- real: 13.5,
3193
- text: 'sometext',
3194
- role: 'admin',
3195
- isConfirmed: true,
3196
- __typename: 'UsersSelectItem',
3197
- posts: [
3198
- {
3199
- id: 1,
3200
- authorId: 1,
3201
- content: '1MESSAGE',
3202
- __typename: 'UsersPostsRelation',
3203
- },
3204
- {
3205
- id: 2,
3206
- authorId: 1,
3207
- content: '2MESSAGE',
3208
- __typename: 'UsersPostsRelation',
3209
- },
3210
- {
3211
- id: 3,
3212
- authorId: 1,
3213
- content: '3MESSAGE',
3214
- __typename: 'UsersPostsRelation',
3215
- },
3216
-
3217
- {
3218
- id: 6,
3219
- authorId: 1,
3220
- content: '4MESSAGE',
3221
- __typename: 'UsersPostsRelation',
3222
- },
3223
- ],
3224
- },
3225
- postsSingle: {
3226
- id: 1,
3227
- authorId: 1,
3228
- content: '1MESSAGE',
3229
- __typename: 'PostsSelectItem',
3230
- author: {
3231
- id: 1,
3232
- name: 'FirstUser',
3233
- email: 'userOne@notmail.com',
3234
- textJson: '{"field":"value"}',
3235
- // RQB can't handle blobs in JSON, for now
3236
- // blobBigInt: '10',
3237
- numeric: '250.2',
3238
- createdAt: '2024-04-02T06:44:41.000Z',
3239
- createdAtMs: '2024-04-02T06:44:41.785Z',
3240
- real: 13.5,
3241
- text: 'sometext',
3242
- role: 'admin',
3243
- isConfirmed: true,
3244
- __typename: 'PostsAuthorRelation',
3245
- },
3246
- },
3247
- },
3248
- });
3249
- });
3250
-
3251
- it(`Select array with relations`, async () => {
3252
- const res = await ctx.gql.queryGql(/* GraphQL */ `
3253
- {
3254
- users {
3255
- id
3256
- name
3257
- email
3258
- textJson
3259
- blobBigInt
3260
- numeric
3261
- createdAt
3262
- createdAtMs
3263
- real
3264
- text
3265
- role
3266
- isConfirmed
3267
- __typename
3268
- posts {
3269
- id
3270
- authorId
3271
- content
3272
- __typename
3273
- }
3274
- }
3275
-
3276
- posts {
3277
- id
3278
- authorId
3279
- content
3280
- __typename
3281
- author {
3282
- id
3283
- name
3284
- email
3285
- textJson
3286
- numeric
3287
- createdAt
3288
- createdAtMs
3289
- real
3290
- text
3291
- role
3292
- isConfirmed
3293
- __typename
3294
- }
3295
- }
3296
- }
3297
- `);
3298
-
3299
- expect(res).toStrictEqual({
3300
- data: {
3301
- users: [
3302
- {
3303
- id: 1,
3304
- name: 'FirstUser',
3305
- email: 'userOne@notmail.com',
3306
- textJson: '{"field":"value"}',
3307
- blobBigInt: '10',
3308
- numeric: '250.2',
3309
- createdAt: '2024-04-02T06:44:41.000Z',
3310
- createdAtMs: '2024-04-02T06:44:41.785Z',
3311
- real: 13.5,
3312
- text: 'sometext',
3313
- role: 'admin',
3314
- isConfirmed: true,
3315
- __typename: 'UsersSelectItem',
3316
- posts: [
3317
- {
3318
- id: 1,
3319
- authorId: 1,
3320
- content: '1MESSAGE',
3321
- __typename: 'UsersPostsRelation',
3322
- },
3323
- {
3324
- id: 2,
3325
- authorId: 1,
3326
- content: '2MESSAGE',
3327
- __typename: 'UsersPostsRelation',
3328
- },
3329
- {
3330
- id: 3,
3331
- authorId: 1,
3332
- content: '3MESSAGE',
3333
- __typename: 'UsersPostsRelation',
3334
- },
3335
- {
3336
- id: 6,
3337
- authorId: 1,
3338
- content: '4MESSAGE',
3339
- __typename: 'UsersPostsRelation',
3340
- },
3341
- ],
3342
- },
3343
- {
3344
- id: 2,
3345
- name: 'SecondUser',
3346
- email: null,
3347
- textJson: null,
3348
- blobBigInt: null,
3349
- numeric: null,
3350
- createdAt: '2024-04-02T06:44:41.000Z',
3351
- createdAtMs: null,
3352
- real: null,
3353
- text: null,
3354
- role: 'user',
3355
- isConfirmed: null,
3356
- posts: [],
3357
- __typename: 'UsersSelectItem',
3358
- },
3359
- {
3360
- id: 5,
3361
- name: 'FifthUser',
3362
- email: null,
3363
- textJson: null,
3364
- blobBigInt: null,
3365
- numeric: null,
3366
- createdAt: '2024-04-02T06:44:41.000Z',
3367
- createdAtMs: null,
3368
- real: null,
3369
- text: null,
3370
- role: 'user',
3371
- isConfirmed: null,
3372
- posts: [
3373
- {
3374
- id: 4,
3375
- authorId: 5,
3376
- content: '1MESSAGE',
3377
- __typename: 'UsersPostsRelation',
3378
- },
3379
- {
3380
- id: 5,
3381
- authorId: 5,
3382
- content: '2MESSAGE',
3383
- __typename: 'UsersPostsRelation',
3384
- },
3385
- ],
3386
- __typename: 'UsersSelectItem',
3387
- },
3388
- ],
3389
- posts: [
3390
- {
3391
- id: 1,
3392
- authorId: 1,
3393
- content: '1MESSAGE',
3394
- __typename: 'PostsSelectItem',
3395
- author: {
3396
- id: 1,
3397
- name: 'FirstUser',
3398
- email: 'userOne@notmail.com',
3399
- textJson: '{"field":"value"}',
3400
- // RQB can't handle blobs in JSON, for now
3401
- // blobBigInt: '10',
3402
- numeric: '250.2',
3403
- createdAt: '2024-04-02T06:44:41.000Z',
3404
- createdAtMs: '2024-04-02T06:44:41.785Z',
3405
- real: 13.5,
3406
- text: 'sometext',
3407
- role: 'admin',
3408
- isConfirmed: true,
3409
- __typename: 'PostsAuthorRelation',
3410
- },
3411
- },
3412
- {
3413
- id: 2,
3414
- authorId: 1,
3415
- content: '2MESSAGE',
3416
- __typename: 'PostsSelectItem',
3417
- author: {
3418
- id: 1,
3419
- name: 'FirstUser',
3420
- email: 'userOne@notmail.com',
3421
- textJson: '{"field":"value"}',
3422
- // RQB can't handle blobs in JSON, for now
3423
- // blobBigInt: '10',
3424
- numeric: '250.2',
3425
- createdAt: '2024-04-02T06:44:41.000Z',
3426
- createdAtMs: '2024-04-02T06:44:41.785Z',
3427
- real: 13.5,
3428
- text: 'sometext',
3429
- role: 'admin',
3430
- isConfirmed: true,
3431
- __typename: 'PostsAuthorRelation',
3432
- },
3433
- },
3434
- {
3435
- id: 3,
3436
- authorId: 1,
3437
- content: '3MESSAGE',
3438
- __typename: 'PostsSelectItem',
3439
- author: {
3440
- id: 1,
3441
- name: 'FirstUser',
3442
- email: 'userOne@notmail.com',
3443
- textJson: '{"field":"value"}',
3444
- // RQB can't handle blobs in JSON, for now
3445
- // blobBigInt: '10',
3446
- numeric: '250.2',
3447
- createdAt: '2024-04-02T06:44:41.000Z',
3448
- createdAtMs: '2024-04-02T06:44:41.785Z',
3449
- real: 13.5,
3450
- text: 'sometext',
3451
- role: 'admin',
3452
- isConfirmed: true,
3453
- __typename: 'PostsAuthorRelation',
3454
- },
3455
- },
3456
- {
3457
- id: 4,
3458
- authorId: 5,
3459
- content: '1MESSAGE',
3460
- __typename: 'PostsSelectItem',
3461
- author: {
3462
- id: 5,
3463
- name: 'FifthUser',
3464
- email: null,
3465
- textJson: null,
3466
- // RQB can't handle blobs in JSON, for now
3467
- // blobBigInt: null,
3468
- numeric: null,
3469
- createdAt: '2024-04-02T06:44:41.000Z',
3470
- createdAtMs: null,
3471
- real: null,
3472
- text: null,
3473
- role: 'user',
3474
- isConfirmed: null,
3475
- __typename: 'PostsAuthorRelation',
3476
- },
3477
- },
3478
- {
3479
- id: 5,
3480
- authorId: 5,
3481
- content: '2MESSAGE',
3482
- __typename: 'PostsSelectItem',
3483
- author: {
3484
- id: 5,
3485
- name: 'FifthUser',
3486
- email: null,
3487
- textJson: null,
3488
- // RQB can't handle blobs in JSON, for now
3489
- // blobBigInt: null,
3490
- numeric: null,
3491
- createdAt: '2024-04-02T06:44:41.000Z',
3492
- createdAtMs: null,
3493
- real: null,
3494
- text: null,
3495
- role: 'user',
3496
- isConfirmed: null,
3497
- __typename: 'PostsAuthorRelation',
3498
- },
3499
- },
3500
- {
3501
- id: 6,
3502
- authorId: 1,
3503
- content: '4MESSAGE',
3504
- __typename: 'PostsSelectItem',
3505
- author: {
3506
- id: 1,
3507
- name: 'FirstUser',
3508
- email: 'userOne@notmail.com',
3509
- textJson: '{"field":"value"}',
3510
- // RQB can't handle blobs in JSON, for now
3511
- // blobBigInt: '10',
3512
- numeric: '250.2',
3513
- createdAt: '2024-04-02T06:44:41.000Z',
3514
- createdAtMs: '2024-04-02T06:44:41.785Z',
3515
- real: 13.5,
3516
- text: 'sometext',
3517
- role: 'admin',
3518
- isConfirmed: true,
3519
- __typename: 'PostsAuthorRelation',
3520
- },
3521
- },
3522
- ],
3523
- },
3524
- });
3525
- });
3526
-
3527
- it(`Insert single`, async () => {
3528
- const res = await ctx.gql.queryGql(/* GraphQL */ `
3529
- mutation {
3530
- insertIntoUsersSingle(
3531
- values: {
3532
- id: 3
3533
- name: "ThirdUser"
3534
- email: "userThree@notmail.com"
3535
- textJson: "{ \\"field\\": \\"value\\" }"
3536
- blobBigInt: "10"
3537
- numeric: "250.2"
3538
- createdAt: "2024-04-02T06:44:41.785Z"
3539
- createdAtMs: "2024-04-02T06:44:41.785Z"
3540
- real: 13.5
3541
- text: "sometext"
3542
- role: admin
3543
- isConfirmed: true
3544
- }
3545
- ) {
3546
- id
3547
- name
3548
- email
3549
- textJson
3550
- blobBigInt
3551
- numeric
3552
- createdAt
3553
- createdAtMs
3554
- real
3555
- text
3556
- role
3557
- isConfirmed
3558
- __typename
3559
- }
3560
- }
3561
- `);
3562
-
3563
- expect(res).toStrictEqual({
3564
- data: {
3565
- insertIntoUsersSingle: {
3566
- id: 3,
3567
- name: 'ThirdUser',
3568
- email: 'userThree@notmail.com',
3569
- textJson: '{"field":"value"}',
3570
- blobBigInt: '10',
3571
- numeric: '250.2',
3572
- createdAt: '2024-04-02T06:44:41.000Z',
3573
- createdAtMs: '2024-04-02T06:44:41.785Z',
3574
- real: 13.5,
3575
- text: 'sometext',
3576
- role: 'admin',
3577
- isConfirmed: true,
3578
- __typename: 'UsersItem',
3579
- },
3580
- },
3581
- });
3582
- });
3583
-
3584
- it(`Insert array`, async () => {
3585
- const res = await ctx.gql.queryGql(/* GraphQL */ `
3586
- mutation {
3587
- insertIntoUsers(
3588
- values: [
3589
- {
3590
- id: 3
3591
- name: "ThirdUser"
3592
- email: "userThree@notmail.com"
3593
- textJson: "{ \\"field\\": \\"value\\" }"
3594
- blobBigInt: "10"
3595
- numeric: "250.2"
3596
- createdAt: "2024-04-02T06:44:41.785Z"
3597
- createdAtMs: "2024-04-02T06:44:41.785Z"
3598
- real: 13.5
3599
- text: "sometext"
3600
- role: admin
3601
- isConfirmed: true
3602
- }
3603
- {
3604
- id: 4
3605
- name: "FourthUser"
3606
- email: "userFour@notmail.com"
3607
- textJson: "{ \\"field\\": \\"value\\" }"
3608
- blobBigInt: "10"
3609
- numeric: "250.2"
3610
- createdAt: "2024-04-02T06:44:41.785Z"
3611
- createdAtMs: "2024-04-02T06:44:41.785Z"
3612
- real: 13.5
3613
- text: "sometext"
3614
- role: user
3615
- isConfirmed: false
3616
- }
3617
- ]
3618
- ) {
3619
- id
3620
- name
3621
- email
3622
- textJson
3623
- blobBigInt
3624
- numeric
3625
- createdAt
3626
- createdAtMs
3627
- real
3628
- text
3629
- role
3630
- isConfirmed
3631
- __typename
3632
- }
3633
- }
3634
- `);
3635
-
3636
- expect(res).toStrictEqual({
3637
- data: {
3638
- insertIntoUsers: [
3639
- {
3640
- id: 3,
3641
- name: 'ThirdUser',
3642
- email: 'userThree@notmail.com',
3643
- textJson: '{"field":"value"}',
3644
- blobBigInt: '10',
3645
- numeric: '250.2',
3646
- createdAt: '2024-04-02T06:44:41.000Z',
3647
- createdAtMs: '2024-04-02T06:44:41.785Z',
3648
- real: 13.5,
3649
- text: 'sometext',
3650
- role: 'admin',
3651
- isConfirmed: true,
3652
- __typename: 'UsersItem',
3653
- },
3654
- {
3655
- id: 4,
3656
- name: 'FourthUser',
3657
- email: 'userFour@notmail.com',
3658
- textJson: '{"field":"value"}',
3659
- blobBigInt: '10',
3660
- numeric: '250.2',
3661
- createdAt: '2024-04-02T06:44:41.000Z',
3662
- createdAtMs: '2024-04-02T06:44:41.785Z',
3663
- real: 13.5,
3664
- text: 'sometext',
3665
- role: 'user',
3666
- isConfirmed: false,
3667
- __typename: 'UsersItem',
3668
- },
3669
- ],
3670
- },
3671
- });
3672
- });
3673
-
3674
- it(`Update`, async () => {
3675
- const res = await ctx.gql.queryGql(/* GraphQL */ `
3676
- mutation {
3677
- updateCustomers(set: { isConfirmed: true, address: "Edited" }) {
3678
- id
3679
- address
3680
- isConfirmed
3681
- registrationDate
3682
- userId
3683
- __typename
3684
- }
3685
- }
3686
- `);
3687
-
3688
- expect(res).toStrictEqual({
3689
- data: {
3690
- updateCustomers: [
3691
- {
3692
- id: 1,
3693
- address: 'Edited',
3694
- isConfirmed: true,
3695
- registrationDate: '2024-03-27T03:54:45.235Z',
3696
- userId: 1,
3697
- __typename: 'CustomersItem',
3698
- },
3699
- {
3700
- id: 2,
3701
- address: 'Edited',
3702
- isConfirmed: true,
3703
- registrationDate: '2024-03-27T03:55:42.358Z',
3704
- userId: 2,
3705
- __typename: 'CustomersItem',
3706
- },
3707
- ],
3708
- },
3709
- });
3710
- });
3711
-
3712
- it(`Delete`, async () => {
3713
- const res = await ctx.gql.queryGql(/* GraphQL */ `
3714
- mutation {
3715
- deleteFromCustomers {
3716
- id
3717
- address
3718
- isConfirmed
3719
- registrationDate
3720
- userId
3721
- __typename
3722
- }
3723
- }
3724
- `);
3725
-
3726
- expect(res).toStrictEqual({
3727
- data: {
3728
- deleteFromCustomers: [
3729
- {
3730
- id: 1,
3731
- address: 'AdOne',
3732
- isConfirmed: false,
3733
- registrationDate: '2024-03-27T03:54:45.235Z',
3734
- userId: 1,
3735
- __typename: 'CustomersItem',
3736
- },
3737
- {
3738
- id: 2,
3739
- address: 'AdTwo',
3740
- isConfirmed: false,
3741
- registrationDate: '2024-03-27T03:55:42.358Z',
3742
- userId: 2,
3743
- __typename: 'CustomersItem',
3744
- },
3745
- ],
3746
- },
3747
- });
3748
- });
3749
- });