Skip to content

Commit

Permalink
Move argument metadata docs (#3683)
Browse files Browse the repository at this point in the history
  • Loading branch information
DoctorJohn authored Oct 31, 2024
1 parent 8859ad3 commit 3e2b9bf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
21 changes: 0 additions & 21 deletions docs/general/queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]: ...
```
27 changes: 27 additions & 0 deletions docs/types/resolvers.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,33 @@ Like this you will get the following responses:

</CodeGrid>

### 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
Expand Down

0 comments on commit 3e2b9bf

Please sign in to comment.