Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5e79792

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

File tree

Expand file treeCollapse file tree

1 file changed

+5
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-2
lines changed

‎graphene_pydantic/converters.py

Copy file name to clipboardExpand all lines: graphene_pydantic/converters.py
+5-2Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.