Skip to content

Commit 8d708f4

Browse files
committed
buildClientSchema: Throws when missing directive locations
Replicates graphql/graphql-js@c8a5792
1 parent b45df3d commit 8d708f4

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ a query language for APIs created by Facebook.
1212
[![Python 3 Status](https://pyup.io/repos/github/graphql-python/graphql-core-next/python-3-shield.svg)](https://pyup.io/repos/github/graphql-python/graphql-core-next/)
1313

1414
The current version 1.0.0 of GraphQL-core-next is up-to-date with GraphQL.js
15-
version 14.0.0. All parts of the API are covered by an extensive test suite of
16-
currently 1603 unit tests.
15+
version 14.0.1. All parts of the API are covered by an extensive test suite of
16+
currently 1604 unit tests.
1717

1818

1919
## Documentation

graphql/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"""
3939

4040
__version__ = '1.0.0'
41-
__version_js__ = '14.0.0'
41+
__version_js__ = '14.0.1'
4242

4343
# The primary entry point into fulfilling a GraphQL request.
4444

graphql/utilities/build_client_schema.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ def build_directive(directive_introspection: Dict) -> GraphQLDirective:
238238
raise TypeError(
239239
'Introspection result missing directive args:'
240240
f' {directive_introspection!r}')
241+
if directive_introspection.get('locations') is None:
242+
raise TypeError(
243+
'Introspection result missing directive locations:'
244+
f' {directive_introspection!r}')
241245
return GraphQLDirective(
242246
name=directive_introspection['name'],
243247
description=directive_introspection.get('description'),

tests/utilities/test_build_client_schema.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,21 @@ def throws_when_missing_interfaces():
388388
" 'type': {'kind': 'SCALAR', 'name': 'String', 'ofType': None},"
389389
" 'isDeprecated': False}]}")
390390

391+
def throws_when_missing_directive_locations():
392+
introspection = {
393+
'__schema': {
394+
'types': [],
395+
'directives': [{'name': 'test', 'args': []}]
396+
}
397+
}
398+
399+
with raises(TypeError) as exc_info:
400+
build_client_schema(introspection)
401+
402+
assert str(exc_info.value) == (
403+
'Introspection result missing directive locations:'
404+
" {'name': 'test', 'args': []}")
405+
391406

392407
def describe_very_deep_decorators_are_not_supported():
393408

0 commit comments

Comments
 (0)