mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-13 13:16:49 +03:00
Improved assertion messages. Fixed #400
This commit is contained in:
parent
51b72d8dc8
commit
ba29de5670
|
@ -43,7 +43,9 @@ def resolve_type(resolve_type_func, map, type_name, root, context, info):
|
||||||
|
|
||||||
if inspect.isclass(_type) and issubclass(_type, ObjectType):
|
if inspect.isclass(_type) and issubclass(_type, ObjectType):
|
||||||
graphql_type = map.get(_type._meta.name)
|
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 graphql_type
|
||||||
|
|
||||||
return _type
|
return _type
|
||||||
|
@ -71,7 +73,9 @@ class TypeMap(GraphQLTypeMap):
|
||||||
if type._meta.name in map:
|
if type._meta.name in map:
|
||||||
_type = map[type._meta.name]
|
_type = map[type._meta.name]
|
||||||
if isinstance(_type, GrapheneGraphQLType):
|
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
|
return map
|
||||||
|
|
||||||
if issubclass(type, ObjectType):
|
if issubclass(type, ObjectType):
|
||||||
|
@ -132,7 +136,9 @@ class TypeMap(GraphQLTypeMap):
|
||||||
if type._meta.name in map:
|
if type._meta.name in map:
|
||||||
_type = map[type._meta.name]
|
_type = map[type._meta.name]
|
||||||
if isinstance(_type, GrapheneGraphQLType):
|
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
|
return _type
|
||||||
|
|
||||||
def interfaces():
|
def interfaces():
|
||||||
|
@ -155,7 +161,9 @@ class TypeMap(GraphQLTypeMap):
|
||||||
if type._meta.name in map:
|
if type._meta.name in map:
|
||||||
_type = map[type._meta.name]
|
_type = map[type._meta.name]
|
||||||
if isinstance(_type, GrapheneInterfaceType):
|
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
|
return _type
|
||||||
|
|
||||||
_resolve_type = None
|
_resolve_type = None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user