File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff 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+
4757There 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
70101Troubleshooting
71102---------------
You can’t perform that action at this time.
0 commit comments