Skip to content

Commit 608e972

Browse files
committed
Better type checking when creating GraphQL types
Also add tests for the type checks, improving coverage.
1 parent 5ac32f2 commit 608e972

20 files changed

+885
-224
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ a query language for APIs created by Facebook.
1313
[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
1414

1515
The current version 1.0.5 of GraphQL-core-next is up-to-date with GraphQL.js version
16-
14.3.1. All parts of the API are covered by an extensive test suite of currently 1825
16+
14.3.1. All parts of the API are covered by an extensive test suite of currently 1877
1717
unit tests.
1818

1919

graphql/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
GraphQLScalarType,
5454
GraphQLObjectType,
5555
GraphQLInterfaceType,
56-
GraphQLInterfaceList,
5756
GraphQLUnionType,
5857
GraphQLEnumType,
5958
GraphQLInputObjectType,
@@ -134,7 +133,6 @@
134133
assert_valid_schema,
135134
# Types
136135
GraphQLType,
137-
GraphQLTypeList,
138136
GraphQLInputType,
139137
GraphQLOutputType,
140138
GraphQLLeafType,
@@ -406,7 +404,6 @@
406404
"GraphQLScalarType",
407405
"GraphQLObjectType",
408406
"GraphQLInterfaceType",
409-
"GraphQLInterfaceList",
410407
"GraphQLUnionType",
411408
"GraphQLEnumType",
412409
"GraphQLInputObjectType",
@@ -476,7 +473,6 @@
476473
"validate_schema",
477474
"assert_valid_schema",
478475
"GraphQLType",
479-
"GraphQLTypeList",
480476
"GraphQLInputType",
481477
"GraphQLOutputType",
482478
"GraphQLLeafType",

graphql/error/invalid.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ def __repr__(self):
1010
def __str__(self):
1111
return "INVALID"
1212

13+
def __hash__(self):
14+
return hash(InvalidType)
15+
1316
def __bool__(self):
1417
return False
1518

graphql/pyutils/frozen_dict.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
__all__ = ["FrozenDict"]
1+
from typing import Dict, TypeVar
22

33
from .frozen_error import FrozenError
44

5+
__all__ = ["FrozenDict"]
6+
7+
K = TypeVar("K")
8+
T = TypeVar("T", covariant=True)
9+
510

6-
class FrozenDict(dict):
11+
class FrozenDict(Dict[K, T]):
712
"""Dictionary that can only be read, but not changed."""
813

914
def __delitem__(self, key):

graphql/pyutils/frozen_list.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
__all__ = ["FrozenList"]
1+
from typing import List, TypeVar
22

33
from .frozen_error import FrozenError
44

5+
__all__ = ["FrozenList"]
6+
7+
8+
T = TypeVar("T", covariant=True)
9+
510

6-
class FrozenList(list):
11+
class FrozenList(List[T]):
712
"""List that can only be read, but not changed."""
813

914
def __delitem__(self, key):

graphql/type/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
GraphQLScalarType,
5959
GraphQLObjectType,
6060
GraphQLInterfaceType,
61-
GraphQLInterfaceList,
6261
GraphQLUnionType,
6362
GraphQLEnumType,
6463
GraphQLInputObjectType,
@@ -67,7 +66,6 @@
6766
GraphQLNonNull,
6867
# Types
6968
GraphQLType,
70-
GraphQLTypeList,
7169
GraphQLInputType,
7270
GraphQLOutputType,
7371
GraphQLLeafType,
@@ -187,7 +185,6 @@
187185
"GraphQLScalarType",
188186
"GraphQLObjectType",
189187
"GraphQLInterfaceType",
190-
"GraphQLInterfaceList",
191188
"GraphQLUnionType",
192189
"GraphQLEnumType",
193190
"GraphQLInputObjectType",
@@ -196,7 +193,6 @@
196193
"GraphQLList",
197194
"GraphQLNonNull",
198195
"GraphQLType",
199-
"GraphQLTypeList",
200196
"GraphQLInputType",
201197
"GraphQLOutputType",
202198
"GraphQLLeafType",

0 commit comments

Comments
 (0)