Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pydantic date types #100

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions graphene_pydantic/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
from pydantic import BaseModel
from pydantic.fields import FieldInfo
from pydantic_core import PydanticUndefined
from pydantic.types import (
PastDate,
FutureDate,
PastDatetime,
FutureDatetime,
AwareDatetime,
NaiveDatetime,
)

from .registry import Placeholder, Registry
from .util import construct_union_class_name, evaluate_forward_ref
Expand Down Expand Up @@ -213,9 +221,15 @@ def find_graphene_type(
return UUID
elif type_ in (str, bytes):
return String
elif type_ == datetime.datetime:
elif type_ in [
datetime.datetime,
PastDatetime,
FutureDatetime,
AwareDatetime,
NaiveDatetime
]:
return DateTime
elif type_ == datetime.date:
elif type_ in [datetime.date, PastDate, FutureDate]:
return Date
elif type_ == datetime.time:
return Time
Expand Down
Loading