Skip to content

Commit f07069e

Browse files
committed
Add documentation about the property type hint auto-guessing
1 parent e2f29bb commit f07069e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/annotations/index.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,27 @@ In the previous example, the generated `resolve` config of the `something` field
116116

117117
## Type & Args auto-guessing
118118

119+
### @Field type auto-guessing when defined on a property with a type hint
120+
121+
The type of the `@Field` annotation can be auto-guessed if it's defined on a property with a type hint.
122+
If the property has a usable type hint this is used and no futher guessing is done.
123+
124+
For example:
125+
126+
```php
127+
/**
128+
* @GQL\Type
129+
*/
130+
class MyType {
131+
/**
132+
* @GQL\Field
133+
*/
134+
protected string $property;
135+
}
136+
```
137+
138+
In this example, the type `String!` will be auto-guessed from the type hint of the property.
139+
119140
### @Field type auto-guessing from Doctrine ORM Annotations
120141

121142
Based on other Doctrine annotations on your fields, the corresponding GraphQL type can sometimes be guessed automatically.

0 commit comments

Comments
 (0)