Skip to content

Commit b4e2867

Browse files
committed
Adding GraphQLite mapping of input types documentation
1 parent 028cfaa commit b4e2867

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

doc/graphqlite.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,40 @@ $db->table('users')
167167
->column('name')->string(50)->graphqlField()
168168
->logged()->right('CAN_SEE_NAME')->failWith(null);
169169
```
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+
```

0 commit comments

Comments
 (0)