descriptions for arguments

Is there any way to add descriptions to arguments currently? I think it's a drawback that we cannot add stuff like deprecated directives and descriptions to arguments just because we use typehints.
@strawberry.field()
def my_field(parent, info, my_arg: str):
pass
@strawberry.field()
def my_field(parent, info, my_arg: str):
pass
Instead of this, does python support something like:
@strawberry.field()
def my_field(parent, info, my_arg: GraphQLString(description="", deprecated=True)):
pass
@strawberry.field()
def my_field(parent, info, my_arg: GraphQLString(description="", deprecated=True)):
pass
That would be cool
7 Replies
Aryan Iyappan
Aryan IyappanOP3y ago
I think this will be possible:
from typing import Annotated

@strawberry.field()
def my_field(parent, info, my_arg: Annotated[str, Field(description="my field description", deprecated=True)]):
pass
from typing import Annotated

@strawberry.field()
def my_field(parent, info, my_arg: Annotated[str, Field(description="my field description", deprecated=True)]):
pass
So the following will also be possible:
from typing import Annotated

@strawberry.type()
class UserType:
username: Annotated[str, Field(description="username description", deprecated=True)]
from typing import Annotated

@strawberry.type()
class UserType:
username: Annotated[str, Field(description="username description", deprecated=True)]
This looks sorta clean. Is this already possible but not mentioned in the docs? @jkimbo @patrick.py This is assuming we have a class named Field from strawberry that holds the metadata
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Aryan Iyappan
Aryan IyappanOP3y ago
Nope this is about arguments, the one about fields was related
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Aryan Iyappan
Aryan IyappanOP3y ago
Oh! I didnt notice it! Thanks!
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Aryan Iyappan
Aryan IyappanOP3y ago
Maybe someone should create an issue regarding this
Want results from more Discord servers?
Add your server