Skip to content

Commit 7312565

Browse files
committed
add more tests
1 parent 61dc3d5 commit 7312565

File tree

4 files changed

+558
-0
lines changed

4 files changed

+558
-0
lines changed

test/expected/issue_237_field_merging.out

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
begin;
22
-- https://github.com/supabase/pg_graphql/issues/237
3+
savepoint a;
34
create table blog_post(
45
id int primary key,
56
a text,
@@ -69,4 +70,174 @@ begin;
6970
}
7071
(1 row)
7172

73+
rollback to savepoint a;
74+
create table account(
75+
id serial primary key,
76+
email varchar(255) not null
77+
);
78+
insert into public.account(email)
79+
values
80+
('aardvark@x.com');
81+
create table blog(
82+
id serial primary key,
83+
owner_id integer not null references account(id),
84+
name varchar(255) not null
85+
);
86+
insert into blog(owner_id, name)
87+
values
88+
(1, 'A: Blog 1');
89+
select jsonb_pretty(graphql.resolve($$ {
90+
accountCollection {
91+
edges {
92+
node {
93+
email
94+
email
95+
id_alias: id
96+
id_alias: id
97+
}
98+
}
99+
}
100+
}$$));
101+
jsonb_pretty
102+
----------------------------------------------------
103+
{ +
104+
"data": { +
105+
"accountCollection": { +
106+
"edges": [ +
107+
{ +
108+
"node": { +
109+
"email": "aardvark@x.com",+
110+
"id_alias": 1 +
111+
} +
112+
} +
113+
] +
114+
} +
115+
} +
116+
}
117+
(1 row)
118+
119+
select jsonb_pretty(graphql.resolve($$ {
120+
accountCollection(first: 1) {
121+
edges {
122+
node {
123+
id
124+
email
125+
}
126+
}
127+
}
128+
accountCollection(first: 1) {
129+
edges {
130+
node {
131+
id
132+
email
133+
}
134+
}
135+
}
136+
}$$));
137+
jsonb_pretty
138+
---------------------------------------------------
139+
{ +
140+
"data": { +
141+
"accountCollection": { +
142+
"edges": [ +
143+
{ +
144+
"node": { +
145+
"id": 1, +
146+
"email": "aardvark@x.com"+
147+
} +
148+
} +
149+
] +
150+
} +
151+
} +
152+
}
153+
(1 row)
154+
155+
select jsonb_pretty(graphql.resolve($$ {
156+
accountCollection(first: $count) {
157+
edges {
158+
node {
159+
id
160+
email
161+
}
162+
}
163+
}
164+
accountCollection(first: $count) {
165+
edges {
166+
node {
167+
id
168+
email
169+
}
170+
}
171+
}
172+
}$$,
173+
jsonb_build_object(
174+
'count', 1
175+
)));
176+
jsonb_pretty
177+
---------------------------------------------------
178+
{ +
179+
"data": { +
180+
"accountCollection": { +
181+
"edges": [ +
182+
{ +
183+
"node": { +
184+
"id": 1, +
185+
"email": "aardvark@x.com"+
186+
} +
187+
} +
188+
] +
189+
} +
190+
} +
191+
}
192+
(1 row)
193+
194+
select jsonb_pretty(graphql.resolve($$ {
195+
accountCollection {
196+
edges {
197+
cursor
198+
cursor
199+
node {
200+
id
201+
email
202+
}
203+
node {
204+
id
205+
email
206+
}
207+
}
208+
edges {
209+
cursor
210+
cursor
211+
node {
212+
id
213+
email
214+
}
215+
node {
216+
id
217+
email
218+
}
219+
}
220+
}
221+
}
222+
223+
$$));
224+
jsonb_pretty
225+
---------------------------------------------------
226+
{ +
227+
"data": { +
228+
"accountCollection": { +
229+
"edges": [ +
230+
{ +
231+
"node": { +
232+
"id": 1, +
233+
"email": "aardvark@x.com"+
234+
}, +
235+
"cursor": "WzFd" +
236+
} +
237+
] +
238+
} +
239+
} +
240+
}
241+
(1 row)
242+
72243
rollback;

test/expected/issue_237_field_merging_mismatched.out

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
begin;
22
-- https://github.com/supabase/pg_graphql/issues/237
3+
savepoint a;
34
create table blog_post(
45
id int primary key,
56
a text,
@@ -107,4 +108,165 @@ begin;
107108
}
108109
(1 row)
109110

111+
rollback to savepoint a;
112+
create table account(
113+
id serial primary key,
114+
email varchar(255) not null
115+
);
116+
insert into public.account(email)
117+
values
118+
('aardvark@x.com');
119+
create table blog(
120+
id serial primary key,
121+
owner_id integer not null references account(id),
122+
name varchar(255) not null
123+
);
124+
insert into blog(owner_id, name)
125+
values
126+
(1, 'A: Blog 1');
127+
select jsonb_pretty(graphql.resolve($$ {
128+
accountCollection {
129+
edges {
130+
node {
131+
email: id
132+
email
133+
}
134+
}
135+
}
136+
}$$));
137+
jsonb_pretty
138+
----------------------------------------------------------------
139+
{ +
140+
"data": null, +
141+
"errors": [ +
142+
{ +
143+
"message": "Fields `email` and `id` are different"+
144+
} +
145+
] +
146+
}
147+
(1 row)
148+
149+
select jsonb_pretty(graphql.resolve($$ {
150+
accountCollection(first: 1) {
151+
edges {
152+
node {
153+
id
154+
email
155+
}
156+
}
157+
}
158+
accountCollection(first: 2) {
159+
edges {
160+
node {
161+
id
162+
email
163+
}
164+
}
165+
}
166+
}$$));
167+
jsonb_pretty
168+
----------------------------------------------------------------------------------------
169+
{ +
170+
"errors": [ +
171+
{ +
172+
"message": "Two fields named `accountCollection` have different arguments"+
173+
} +
174+
] +
175+
}
176+
(1 row)
177+
178+
select jsonb_pretty(graphql.resolve($$ {
179+
accountCollection(first: $count) {
180+
edges {
181+
node {
182+
id
183+
email
184+
}
185+
}
186+
}
187+
accountCollection(first: 1) {
188+
edges {
189+
node {
190+
id
191+
email
192+
}
193+
}
194+
}
195+
}$$,
196+
jsonb_build_object(
197+
'count', 1
198+
)));
199+
jsonb_pretty
200+
----------------------------------------------------------------------------------------
201+
{ +
202+
"errors": [ +
203+
{ +
204+
"message": "Two fields named `accountCollection` have different arguments"+
205+
} +
206+
] +
207+
}
208+
(1 row)
209+
210+
select jsonb_pretty(graphql.resolve($$ {
211+
accountCollection(first: $count) {
212+
edges {
213+
node {
214+
id
215+
email
216+
}
217+
}
218+
}
219+
accountCollection(first: $num) {
220+
edges {
221+
node {
222+
id
223+
email
224+
}
225+
}
226+
}
227+
}$$,
228+
jsonb_build_object(
229+
'count', 1,
230+
'num', 1
231+
)));
232+
jsonb_pretty
233+
----------------------------------------------------------------------------------------
234+
{ +
235+
"errors": [ +
236+
{ +
237+
"message": "Two fields named `accountCollection` have different arguments"+
238+
} +
239+
] +
240+
}
241+
(1 row)
242+
243+
select jsonb_pretty(graphql.resolve($$ {
244+
accountCollection(first: 1) {
245+
edges {
246+
node {
247+
id
248+
email
249+
}
250+
}
251+
}
252+
accountCollection {
253+
edges {
254+
node {
255+
id
256+
email
257+
}
258+
}
259+
}
260+
}$$));
261+
jsonb_pretty
262+
----------------------------------------------------------------------------------------
263+
{ +
264+
"errors": [ +
265+
{ +
266+
"message": "Two fields named `accountCollection` have different arguments"+
267+
} +
268+
] +
269+
}
270+
(1 row)
271+
110272
rollback;

0 commit comments

Comments
 (0)