Skip to content

Commit 88faade

Browse files
authored
Merge pull request #93 from graphql-python/compat/restore-graphene-2
compat: Restore Graphene 2 support
2 parents d7f0b26 + 01e58d0 commit 88faade

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
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
),

noxfile.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77
"pydantic",
88
("1.9", "1.10", "1.7", "1.8"),
99
)
10-
def tests(session, pydantic):
10+
@parametrize("graphene", ("2.1.9", "3"))
11+
def tests(session, pydantic, graphene):
1112
if sys.version_info > (3, 10) and pydantic in ("1.7", "1.8"):
1213
return session.skip()
14+
if sys.version_info > (3, 10) and graphene != "3":
15+
# Graphene 2.x doesn't support Python 3.11
16+
return session.skip()
1317
session.install(f"pydantic=={pydantic}")
18+
session.install(f"graphene=={graphene}")
1419
session.install("pytest", "pytest-cov", ".")
1520
session.run(
1621
"pytest", "-v", "tests/", "--cov-report=term-missing", "--cov=graphene_pydantic"

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "graphene_pydantic"
3-
version = "0.4.1"
3+
version = "0.4.2"
44
description = "Graphene Pydantic integration"
55
readme = "README.md"
66
repository = "https://github.com/graphql-python/graphene-pydantic"
@@ -25,7 +25,7 @@ keywords = ["api", "graphql", "protocol", "rest", "relay", "graphene", "pydantic
2525

2626
[tool.poetry.dependencies]
2727
python = "^3.7"
28-
graphene = ">=3.0"
28+
graphene = ">=2.1.8"
2929
pydantic = [
3030
{ version = ">=1.0,<2.0", python = ">3.6,<3.12" },
3131
{ version = ">=1.9,<2.0", python = ">=3.10" }

0 commit comments

Comments
 (0)