Skip to content

Commit 5e79792

Browse files
author
Rami Chowdhury
committed
compat: Add check for Graphene 2.x type argument
1 parent 085867a commit 5e79792

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

graphene_pydantic/converters.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
String,
2121
Union,
2222
)
23+
import graphene
2324
from graphene.types.base import BaseType
2425
from graphene.types.datetime import Date, DateTime, Time
2526
from pydantic import BaseModel
@@ -31,6 +32,8 @@
3132

3233
from pydantic import fields
3334

35+
GRAPHENE2 = graphene.VERSION[0] < 3
36+
3437
SHAPE_SINGLETON = (fields.SHAPE_SINGLETON,)
3538
SHAPE_SEQUENTIAL = (
3639
fields.SHAPE_LIST,
@@ -89,7 +92,7 @@ def convert_pydantic_input_field(
8992
"""
9093
declared_type = getattr(field, "type_", None)
9194
field_kwargs.setdefault(
92-
"type_",
95+
"type" if GRAPHENE2 else "type_",
9396
convert_pydantic_type(
9497
declared_type, field, registry, parent_type=parent_type, model=model
9598
),
@@ -118,7 +121,7 @@ def convert_pydantic_field(
118121
"""
119122
declared_type = getattr(field, "type_", None)
120123
field_kwargs.setdefault(
121-
"type",
124+
"type" if GRAPHENE2 else "type_",
122125
convert_pydantic_type(
123126
declared_type, field, registry, parent_type=parent_type, model=model
124127
),

0 commit comments

Comments
 (0)