Skip to content

Commit 63da27a

Browse files
committed
Improve coercion error messages
Related GraphQL-js commits: graphql/graphql-js@dea5aac graphql/graphql-js@136630f
1 parent d512398 commit 63da27a

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

graphql/execution/executor.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,23 @@ def complete_abstract_value(exe_context, return_type, field_asts, info, result):
309309
else:
310310
runtime_type = get_default_resolve_type_fn(result, info, return_type)
311311

312-
if not runtime_type:
313-
return None
312+
assert runtime_type, (
313+
'Could not determine runtime type of value "{}" for field {}.{}.'.format(
314+
result,
315+
info.parent_type,
316+
info.field_name
317+
))
318+
319+
assert isinstance(runtime_type, GraphQLObjectType), (
320+
'{}.resolveType must return an instance of GraphQLObjectType ' +
321+
'for field {}.{}, received "{}".'.format(
322+
return_type,
323+
info.parent_type,
324+
info.field_name,
325+
result,
326+
))
314327

315-
schema = exe_context.schema
316-
if not schema.is_possible_type(return_type, runtime_type):
328+
if not exe_context.schema.is_possible_type(return_type, runtime_type):
317329
raise GraphQLError(
318330
u'Runtime Object type "{}" is not a possible type for "{}".'.format(runtime_type, return_type),
319331
field_asts

0 commit comments

Comments
 (0)