Skip to content

Commit

Permalink
Improved assertion messages. Fixed #400
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary committed Feb 21, 2017
1 parent 51b72d8 commit ba29de5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions graphene/types/typemap.py
Expand Up @@ -43,7 +43,9 @@ def resolve_type(resolve_type_func, map, type_name, root, context, info):

if inspect.isclass(_type) and issubclass(_type, ObjectType):
graphql_type = map.get(_type._meta.name)
assert graphql_type and graphql_type.graphene_type == _type
assert graphql_type and graphql_type.graphene_type == _type, (
'The type {} does not match with the associated graphene type {}.'
).format(_type, graphql_type.graphene_type)
return graphql_type

return _type
Expand Down Expand Up @@ -71,7 +73,9 @@ def graphene_reducer(self, map, type):
if type._meta.name in map:
_type = map[type._meta.name]
if isinstance(_type, GrapheneGraphQLType):
assert _type.graphene_type == type
assert _type.graphene_type == type, (
'Found different types with the same name in the schema: {}, {}.'
).format(_type.graphene_type, type)
return map

if issubclass(type, ObjectType):
Expand Down Expand Up @@ -132,7 +136,9 @@ def construct_objecttype(self, map, type):
if type._meta.name in map:
_type = map[type._meta.name]
if isinstance(_type, GrapheneGraphQLType):
assert _type.graphene_type == type
assert _type.graphene_type == type, (
'Found different types with the same name in the schema: {}, {}.'
).format(_type.graphene_type, type)
return _type

def interfaces():
Expand All @@ -155,7 +161,9 @@ def construct_interface(self, map, type):
if type._meta.name in map:
_type = map[type._meta.name]
if isinstance(_type, GrapheneInterfaceType):
assert _type.graphene_type == type
assert _type.graphene_type == type, (
'Found different types with the same name in the schema: {}, {}.'
).format(_type.graphene_type, type)
return _type

_resolve_type = None
Expand Down

0 comments on commit ba29de5

Please sign in to comment.