Skip to content

Commit 5be9969

Browse files
committed
Fix tests
1 parent 7123e45 commit 5be9969

File tree

8 files changed

+320
-1736
lines changed

8 files changed

+320
-1736
lines changed

test/expected/aggregate.out

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ begin;
4444
((SELECT id FROM blog WHERE name = 'A: Blog 3'), 'Post 1 in A Blog 3', 'Content for post 1 in A Blog 3', '{"travel", "adventure"}', 'PENDING', '2025-04-22 12:00:00'),
4545
((SELECT id FROM blog WHERE name = 'B: Blog 3'), 'Post 1 in B Blog 3', 'Content for post 1 in B Blog 3', '{"tech", "review"}', 'RELEASED', '2025-04-27 12:00:00'),
4646
((SELECT id FROM blog WHERE name = 'B: Blog 3'), 'Post 2 in B Blog 3', 'Content for post 2 in B Blog 3', '{"coding", "tutorial"}', 'PENDING', '2025-05-02 12:00:00');
47-
comment on table blog_post is e'@graphql({"totalCount": {"enabled": true}})';
47+
comment on table account is e'@graphql({"totalCount": {"enabled": true}, "aggregate": {"enabled": true}})';
48+
comment on table blog is e'@graphql({"totalCount": {"enabled": true}, "aggregate": {"enabled": true}})';
49+
comment on table blog_post is e'@graphql({"totalCount": {"enabled": true}, "aggregate": {"enabled": true}})';
4850
-- Test Case 1: Basic Count on accountCollection
4951
select graphql.resolve($$
5052
query {

test/expected/aggregate_directive.out

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
begin;
2-
32
-- Create a simple table without any directives
43
create table product(
54
id serial primary key,
65
name text not null,
76
price numeric not null,
87
stock int not null
98
);
10-
119
insert into product(name, price, stock)
1210
values
1311
('Widget', 9.99, 100),
1412
('Gadget', 19.99, 50),
1513
('Gizmo', 29.99, 25);
16-
1714
-- Try to query aggregate without enabling the directive - should fail
1815
select graphql.resolve($$
1916
{
@@ -31,7 +28,6 @@ $$);
3128

3229
-- Enable aggregates
3330
comment on table product is e'@graphql({"aggregate": {"enabled": true}})';
34-
3531
-- Now aggregates should be available - should succeed
3632
select graphql.resolve($$
3733
{
@@ -56,9 +52,9 @@ select graphql.resolve($$
5652
}
5753
}
5854
$$);
59-
resolve
60-
--------------------------------------------------------------------------------------------------------------------------------------------------------------
61-
{"data": {"productCollection": {"aggregate": {"avg": {"price": 19.99}, "count": 3, "max": {"name": "Widget", "price": 29.99}, "min": {"stock": 25}, "sum": {"price": 59.97, "stock": 175}}}}}
55+
resolve
56+
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
57+
{"data": {"productCollection": {"aggregate": {"avg": {"price": 19.99}, "max": {"name": "Widget", "price": 29.99}, "min": {"stock": 25}, "sum": {"price": 59.97, "stock": 175}, "count": 3}}}}
6258
(1 row)
6359

64-
rollback;
60+
rollback;

test/expected/inflection_types.out

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,19 @@ begin;
2020
'$.data.__schema.types[*].name ? (@ starts with "blog")'
2121
)
2222
);
23-
jsonb_pretty
24-
-------------------------------
23+
jsonb_pretty
24+
---------------------------
2525
"blog_post"
26-
"blog_postAggregate"
27-
"blog_postAvgAggregateResult"
2826
"blog_postConnection"
2927
"blog_postDeleteResponse"
3028
"blog_postEdge"
3129
"blog_postFilter"
3230
"blog_postInsertInput"
3331
"blog_postInsertResponse"
34-
"blog_postMaxAggregateResult"
35-
"blog_postMinAggregateResult"
3632
"blog_postOrderBy"
37-
"blog_postSumAggregateResult"
3833
"blog_postUpdateInput"
3934
"blog_postUpdateResponse"
40-
(15 rows)
35+
(10 rows)
4136

4237
-- Inflection off, Overrides: on
4338
comment on table blog_post is e'@graphql({"name": "BlogZZZ"})';
@@ -55,24 +50,19 @@ begin;
5550
'$.data.__schema.types[*].name ? (@ starts with "Blog")'
5651
)
5752
);
58-
jsonb_pretty
59-
-----------------------------
53+
jsonb_pretty
54+
-------------------------
6055
"BlogZZZ"
61-
"BlogZZZAggregate"
62-
"BlogZZZAvgAggregateResult"
6356
"BlogZZZConnection"
6457
"BlogZZZDeleteResponse"
6558
"BlogZZZEdge"
6659
"BlogZZZFilter"
6760
"BlogZZZInsertInput"
6861
"BlogZZZInsertResponse"
69-
"BlogZZZMaxAggregateResult"
70-
"BlogZZZMinAggregateResult"
7162
"BlogZZZOrderBy"
72-
"BlogZZZSumAggregateResult"
7363
"BlogZZZUpdateInput"
7464
"BlogZZZUpdateResponse"
75-
(15 rows)
65+
(10 rows)
7666

7767
rollback to savepoint a;
7868
-- Inflection on, Overrides: off
@@ -91,24 +81,19 @@ begin;
9181
'$.data.__schema.types[*].name ? (@ starts with "Blog")'
9282
)
9383
);
94-
jsonb_pretty
95-
------------------------------
84+
jsonb_pretty
85+
--------------------------
9686
"BlogPost"
97-
"BlogPostAggregate"
98-
"BlogPostAvgAggregateResult"
9987
"BlogPostConnection"
10088
"BlogPostDeleteResponse"
10189
"BlogPostEdge"
10290
"BlogPostFilter"
10391
"BlogPostInsertInput"
10492
"BlogPostInsertResponse"
105-
"BlogPostMaxAggregateResult"
106-
"BlogPostMinAggregateResult"
10793
"BlogPostOrderBy"
108-
"BlogPostSumAggregateResult"
10994
"BlogPostUpdateInput"
11095
"BlogPostUpdateResponse"
111-
(15 rows)
96+
(10 rows)
11297

11398
-- Inflection on, Overrides: on
11499
comment on table blog_post is e'@graphql({"name": "BlogZZZ"})';
@@ -126,23 +111,18 @@ begin;
126111
'$.data.__schema.types[*].name ? (@ starts with "Blog")'
127112
)
128113
);
129-
jsonb_pretty
130-
-----------------------------
114+
jsonb_pretty
115+
-------------------------
131116
"BlogZZZ"
132-
"BlogZZZAggregate"
133-
"BlogZZZAvgAggregateResult"
134117
"BlogZZZConnection"
135118
"BlogZZZDeleteResponse"
136119
"BlogZZZEdge"
137120
"BlogZZZFilter"
138121
"BlogZZZInsertInput"
139122
"BlogZZZInsertResponse"
140-
"BlogZZZMaxAggregateResult"
141-
"BlogZZZMinAggregateResult"
142123
"BlogZZZOrderBy"
143-
"BlogZZZSumAggregateResult"
144124
"BlogZZZUpdateInput"
145125
"BlogZZZUpdateResponse"
146-
(15 rows)
126+
(10 rows)
147127

148128
rollback;

0 commit comments

Comments
 (0)