Closed hyu9999 closed 4 years ago
Hi! I'm not exactly sure what the desired behavior is, could you maybe post a more explicit description, ideally a pseudo-code sample?
Closing due to inactivity
Hi! I could use that functionality, too!
Problem is the missing mapping of new pydantic data types, such as "EmailStr" or "UUID4", to graphene data types.
Example pydantic model:
from pydantic import BaseModel, EmailStr, UUID4, HttpUrl
class User(BaseModel):
id: UUID4
name: str
email: EmailStr
profileImage: HttpUrl
My idea was to either 1) extend "find_graphene_type" in converters.py @ line 140 (kinda hardcoding it...) or
2) extend the registry with a function similar to:
registry.add_data_type_mapping(from=Pydanitc.EmailStr, to=str)
registry.add_data_type_mapping(from=Pydanitc.HttpUrl, to=str)
registry.add_data_type_mapping(from=Pydanitc.UUID4, to=uuid.UUID)
and then applying the existing converter-function.
3) or use the "type"-value that pydantic provides - as used in ".schema_json()" :
... "email": {"title": "Email", "type": "string", "format": "email"} ...
(thank you for the package btw^^)
@michael-koenig I like your second suggestion! Would you be interested in making a pull request to implement it?
@necaris Sure, I can certainly give it a try :)
@dantheman39 and I are here to help if you need anything -- looking forward to your contribution!
The current supported type is inconsistent with the type supported by pydantic ,for example EmailStr UrlStr etc.