Skip to content

Commit 3186dd2

Browse files
authored
Merge pull request #82 from conao3/feature/38
Mapping pydantic.Field.alias attr as graphene.Field.name
2 parents 4e219fa + 886131c commit 3186dd2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

graphene_pydantic/converters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ def convert_pydantic_field(
125125
)
126126
field_kwargs.setdefault("required", not field.allow_none)
127127
field_kwargs.setdefault("default_value", field.default)
128+
if field.has_alias:
129+
field_kwargs.setdefault("name", field.alias)
128130
# TODO: find a better way to get a field's description. Some ideas include:
129131
# - hunt down the description from the field's schema, or the schema
130132
# from the field's base model

0 commit comments

Comments
 (0)