Skip to content

Commit e5eb47c

Browse files
committed
Make this compatible with older GraphQL 3.1 versions (#43)
1 parent 6239ab7 commit e5eb47c

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/graphql_relay/connection/connection.py

+18-1
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,30 @@
1010
GraphQLFieldResolver,
1111
GraphQLInt,
1212
GraphQLList,
13-
GraphQLNamedOutputType,
1413
GraphQLNonNull,
1514
GraphQLObjectType,
1615
GraphQLString,
1716
Thunk,
1817
)
1918

19+
try:
20+
from graphql import GraphQLNamedOutputType
21+
except ImportError: # GraphQL < 3.1.7
22+
from graphql import (
23+
GraphQLEnumType,
24+
GraphQLInterfaceType,
25+
GraphQLScalarType,
26+
GraphQLUnionType,
27+
)
28+
29+
GraphQLNamedOutputType = Union[ # type: ignore
30+
GraphQLScalarType,
31+
GraphQLObjectType,
32+
GraphQLInterfaceType,
33+
GraphQLUnionType,
34+
GraphQLEnumType,
35+
]
36+
2037
try:
2138
from typing import Protocol
2239
except ImportError: # Python < 3.8

tox.ini

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py3{6,7,8,9,10}, black, flake8, mypy, manifest
2+
envlist = py3{6,7,8,9,10}, black, flake8, mypy, manifest, core310
33
isolated_build = true
44

55
[gh-actions]
@@ -36,6 +36,16 @@ deps = check-manifest>=0.47,<1
3636
commands =
3737
check-manifest -v
3838

39+
[testenv:core310]
40+
basepython = python3.9
41+
deps =
42+
graphql-core==3.1.0
43+
pytest>=6.2,<7
44+
pytest-asyncio>=0.16,<1
45+
pytest-describe>=2,<3
46+
commands =
47+
pytest tests {posargs}
48+
3949
[testenv]
4050
deps =
4151
pytest>=6.2,<7

0 commit comments

Comments
 (0)