You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/Database/SelectFields/NestedRelationLoadingTests/NestedRelationLoadingTest.php
+75-6Lines changed: 75 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,8 @@ public function testQueryNoSelectFields(): void
56
56
57
57
$result = GraphQL::query($graphql);
58
58
59
-
$this->assertSqlQueries(<<<'SQL'
59
+
$this->assertSqlQueries(
60
+
<<<'SQL'
60
61
select * from "users" order by "users"."id" asc;
61
62
select * from "posts" where "posts"."user_id" = ? and "posts"."user_id" is not null order by "posts"."id" asc;
62
63
select * from "comments" where "comments"."post_id" = ? and "comments"."post_id" is not null order by "comments"."id" asc;
@@ -197,7 +198,8 @@ public function testQuerySelect(): void
197
198
198
199
$result = GraphQL::query($graphql);
199
200
200
-
$this->assertSqlQueries(<<<'SQL'
201
+
$this->assertSqlQueries(
202
+
<<<'SQL'
201
203
select "users"."id", "users"."name" from "users" order by "users"."id" asc;
202
204
select * from "posts" where "posts"."user_id" = ? and "posts"."user_id" is not null order by "posts"."id" asc;
203
205
select * from "comments" where "comments"."post_id" = ? and "comments"."post_id" is not null order by "comments"."id" asc;
@@ -338,7 +340,8 @@ public function testQueryWith(): void
338
340
339
341
$result = GraphQL::query($graphql);
340
342
341
-
$this->assertSqlQueries(<<<'SQL'
343
+
$this->assertSqlQueries(
344
+
<<<'SQL'
342
345
select * from "users" order by "users"."id" asc;
343
346
select "posts"."body", "posts"."id", "posts"."title", "posts"."user_id" from "posts" where "posts"."user_id" in (?, ?) order by "posts"."id" asc;
344
347
select "comments"."body", "comments"."id", "comments"."title", "comments"."post_id" from "comments" where "comments"."post_id" in (?, ?, ?, ?) order by "comments"."id" asc;
@@ -475,7 +478,8 @@ public function testQuerySelectAndWith(): void
475
478
476
479
$result = GraphQL::query($graphql);
477
480
478
-
$this->assertSqlQueries(<<<'SQL'
481
+
$this->assertSqlQueries(
482
+
<<<'SQL'
479
483
select "users"."id", "users"."name" from "users" order by "users"."id" asc;
480
484
select "posts"."body", "posts"."id", "posts"."title", "posts"."user_id" from "posts" where "posts"."user_id" in (?, ?) order by "posts"."id" asc;
481
485
select "comments"."body", "comments"."id", "comments"."title", "comments"."post_id" from "comments" where "comments"."post_id" in (?, ?, ?, ?) order by "comments"."id" asc;
@@ -625,7 +629,8 @@ public function testQuerySelectAndWithAndSubArgs(): void
625
629
626
630
$result = GraphQL::query($graphql);
627
631
628
-
$this->assertSqlQueries(<<<'SQL'
632
+
$this->assertSqlQueries(
633
+
<<<'SQL'
629
634
select "users"."id", "users"."name" from "users" order by "users"."id" asc;
630
635
select "posts"."body", "posts"."id", "posts"."title", "posts"."user_id" from "posts" where "posts"."user_id" in (?, ?) and "posts"."flag" = ? order by "posts"."id" asc;
631
636
select "comments"."body", "comments"."id", "comments"."title", "comments"."post_id" from "comments" where "comments"."post_id" in (?, ?) order by "comments"."id" asc;
@@ -751,7 +756,8 @@ public function testQuerySelectAndWithAndNestedSubArgs(): void
751
756
752
757
$result = GraphQL::query($graphql);
753
758
754
-
$this->assertSqlQueries(<<<'SQL'
759
+
$this->assertSqlQueries(
760
+
<<<'SQL'
755
761
select "users"."id", "users"."name" from "users" order by "users"."id" asc;
756
762
select "posts"."body", "posts"."id", "posts"."title", "posts"."user_id" from "posts" where "posts"."user_id" in (?, ?) and "posts"."flag" = ? order by "posts"."id" asc;
757
763
select "comments"."body", "comments"."id", "comments"."title", "comments"."post_id" from "comments" where "comments"."post_id" in (?, ?) and "comments"."flag" = ? order by "comments"."id" asc;
@@ -803,6 +809,69 @@ public function testQuerySelectAndWithAndNestedSubArgs(): void
803
809
$this->assertEquals($expectedResult, $result);
804
810
}
805
811
812
+
publicfunctiontestRelationshipAlias(): void
813
+
{
814
+
$users = factory(User::class, 1)
815
+
->create()
816
+
->each(function (User$user): void {
817
+
factory(Post::class)
818
+
->create([
819
+
'flag' => true,
820
+
'user_id' => $user->id,
821
+
]);
822
+
});
823
+
824
+
825
+
826
+
$graphql = <<<GRAQPHQL
827
+
{
828
+
users(select: true, with: true) {
829
+
id
830
+
name
831
+
flaggedPosts {
832
+
body
833
+
id
834
+
title
835
+
836
+
}
837
+
}
838
+
}
839
+
GRAQPHQL;
840
+
841
+
$this->sqlCounterReset();
842
+
843
+
844
+
$result = GraphQL::query($graphql);
845
+
846
+
$this->assertSqlQueries(
847
+
<<<'SQL'
848
+
select "users"."id", "users"."name" from "users" order by "users"."id" asc;
849
+
select "posts"."body", "posts"."id", "posts"."title", "posts"."user_id" from "posts" where "posts"."user_id" in (?) and "posts"."flag" = ? order by "posts"."id" asc;
0 commit comments