File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -167,3 +167,40 @@ $db->table('users')
167
167
->column('name')->string(50)->graphqlField()
168
168
->logged()->right('CAN_SEE_NAME')->failWith(null);
169
169
```
170
+
171
+ ## Use your beans as input types
172
+
173
+ TDBM will automatically annotate the ` xxxDao::getById() ` method with a ` @Factory ` annotation.
174
+ As a result, you can directly inject you beans as arguments in your GraphQL queries.
175
+
176
+ For instance:
177
+
178
+ ``` php
179
+ class ProductController
180
+ {
181
+ // ...
182
+
183
+ /**
184
+ * @Query()
185
+ * @return Product[]
186
+ */
187
+ public function getProducts(Category $category): array
188
+ {
189
+ // ...
190
+ }
191
+ }
192
+ ```
193
+
194
+ Assuming "Category" is a bean, TDBM-GraphQL will automatically fetch the bean from the database and populate the ` $category `
195
+ argument with it.
196
+
197
+ Your GraphQL query will look like this:
198
+
199
+ ``` graphql
200
+ {
201
+ products (category : { id : 42 }) {
202
+ id
203
+ name
204
+ }
205
+ }
206
+ ```
You can’t perform that action at this time.
0 commit comments