diff --git a/docs/general/queries.md b/docs/general/queries.md index d509212b54..14963a51bd 100644 --- a/docs/general/queries.md +++ b/docs/general/queries.md @@ -77,24 +77,3 @@ class Query: return fruit return None ``` - -Additional metadata can be added to arguments, for example a custom name and -description using `strawberry.argument` with -[typing.Annotated](https://docs.python.org/3/library/typing.html#typing.Annotated): - -```python -@strawberry.type -class Query: - @strawberry.field - def fruits( - self, - is_tasty: Annotated[ - bool | None, - strawberry.argument( - description="Filters out fruits by whenever they're tasty or not", - deprecation_reason="isTasty argument is deprecated, " - "use fruits(taste:SWEET) instead", - ), - ] = None, - ) -> list[str]: ... -``` diff --git a/docs/types/resolvers.md b/docs/types/resolvers.md index 5398828865..8aeb2e328c 100644 --- a/docs/types/resolvers.md +++ b/docs/types/resolvers.md @@ -203,6 +203,33 @@ Like this you will get the following responses: +### Annotated Arguments + +Additional metadata can be added to arguments, for example a custom name or +deprecation reason, using `strawberry.argument` with +[typing.Annotated](https://docs.python.org/3/library/typing.html#typing.Annotated): + +```python +from typing import Optional, Annotated +import strawberry + + +@strawberry.type +class Query: + @strawberry.field + def greet( + self, + name: Optional[str] = strawberry.UNSET, + is_morning: Annotated[ + Optional[bool], + strawberry.argument( + name="morning", + deprecation_reason="The field now automatically detects if it's morning or not", + ), + ] = None, + ) -> str: ... +``` + ## Accessing execution information Sometimes it is useful to access the information for the current execution