Skip to content

Commit 321ef00

Browse files
committed
Adding documentation
1 parent cc0c8d4 commit 321ef00

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ class UserController
4444
}
4545
```
4646

47+
Your methods can type-hint against:
48+
49+
- int
50+
- string
51+
- bool
52+
- float
53+
- DateTimeImmutable or DateTimeInterface
54+
- an array
55+
- any object (if you provide an hydrator for the object type)
56+
4757
There is an additional support for authentication and authorization:
4858

4959
```php
@@ -65,7 +75,28 @@ class UserController
6575
}
6676
```
6777

78+
Type-hinting against arrays
79+
---------------------------
80+
81+
You can type-hint against arrays as long as you document the PHP-Doc correctly:
82+
83+
```php
84+
/**
85+
* @Query
86+
* @return User[] <=== we specify that the array is an array of User objects.
87+
*/
88+
public function users(int $limit, int $offset): array
89+
{
90+
// Some code that returns an array of "users".
91+
// This completely replaces the "resolve" method.
92+
}
93+
```
94+
95+
Type-hinting against objects
96+
----------------------------
6897

98+
When you specify an object type-hint, graphql-controllers will delegate the object creation to an hydrator.
99+
You must pass this hydrator in parameter when building the `ControllerQueryProvider`.
69100

70101
Troubleshooting
71102
---------------

0 commit comments

Comments
 (0)