Skip to content

Commit 7751070

Browse files
committed
Revert deferred test, add a separate one for callable
1 parent 30a4f95 commit 7751070

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

tests/Fixtures/Integration/Models/Blog.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,13 @@ public function getPosts(
3636
return $prefetchedPosts[$this->id];
3737
}
3838

39-
/**
40-
* @param Blog[][] $prefetchedSubBlogs
41-
*
42-
* @return callable(): Blog[]
43-
*/
44-
#[Field]
39+
/** @param Blog[][] $prefetchedSubBlogs */
40+
#[Field(outputType: '[Blog!]!')]
4541
public function getSubBlogs(
4642
#[Prefetch('prefetchSubBlogs')]
4743
array $prefetchedSubBlogs,
48-
): callable {
49-
return fn () => $prefetchedSubBlogs[$this->id];
44+
): Deferred {
45+
return new Deferred(fn () => $prefetchedSubBlogs[$this->id]);
5046
}
5147

5248
/**
@@ -84,4 +80,10 @@ public static function prefetchSubBlogs(iterable $blogs): array
8480

8581
return $subBlogs;
8682
}
83+
84+
/** @return callable(): User */
85+
#[Field]
86+
public function author(): callable {
87+
return fn () => new User('Author', 'author@graphqlite');
88+
}
8789
}

tests/Integration/EndToEndTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2359,6 +2359,9 @@ public function testPrefetchingOfSameTypeInDifferentNestingLevels(): void
23592359
}
23602360
}
23612361
}
2362+
author {
2363+
email
2364+
}
23622365
posts {
23632366
title
23642367
comments {
@@ -2399,6 +2402,9 @@ public function testPrefetchingOfSameTypeInDifferentNestingLevels(): void
23992402
],
24002403
],
24012404
],
2405+
'author' => [
2406+
'email' => 'author@graphqlite',
2407+
],
24022408
'posts' => [
24032409
[
24042410
'title' => 'post-1.1',
@@ -2435,6 +2441,9 @@ public function testPrefetchingOfSameTypeInDifferentNestingLevels(): void
24352441
],
24362442
],
24372443
],
2444+
'author' => [
2445+
'email' => 'author@graphqlite',
2446+
],
24382447
'posts' => [
24392448
[
24402449
'title' => 'post-2.1',

0 commit comments

Comments
 (0)