drizzle-graphql-plus 0.8.8 → 0.8.10

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