Add type annotation for the python type of GraphQL query arguments
Opened this issue · 1 comments
pmantica1 commented
We predominantly use Any
to indicate the python types for GraphQL query arguments. In order to make it clearer what the allowed python types are, we should probably create a type alias that is an union of allowed types and use it throughout the codebase. (For instance, It is not obvious that we use datetime.datetime
for arguments with GraphQLDatetime
types instead of isoformatted strings).
I am thinking of something like:
_QueryArgumentBaseType = Union[bool, int, datetime, date, Decimal]
QueryArgumentType = Union[List[_QueryArgumentBaseType], _QueryArgumentBaseType]
obi1kenobi commented
Yeah, I agree with the overall approach. Probably a non-trivial refactor, but definitely would be nice to have. We'll just have to audit all our scalar types (default and custom) and make sure we cover all valid inputs for all those.