Skip to content

Commit

Permalink
Add support for datetime, date, and time subclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-merrill committed May 17, 2023
1 parent 306a959 commit c3e0d5c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions graphene_pydantic/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ def find_graphene_type(
return Enum.from_enum(type_)
elif issubclass(type_, str):
return String
elif issubclass(type_, datetime.datetime):
return DateTime
elif issubclass(type_, datetime.date):
return Date
elif issubclass(type_, datetime.time):
return Time
else:
raise ConversionError(
f"Don't know how to convert the Pydantic field {field!r} ({field.type_})"
Expand Down

0 comments on commit c3e0d5c

Please sign in to comment.