File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ a query language for APIs created by Facebook.
13
13
[ ![ Code Style] ( https://img.shields.io/badge/code%20style-black-000000.svg )] ( https://github.com/ambv/black )
14
14
15
15
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 1822
16
+ 14.3.1. All parts of the API are covered by an extensive test suite of currently 1823
17
17
unit tests.
18
18
19
19
Original file line number Diff line number Diff line change @@ -51,6 +51,15 @@ def build_client_schema(
51
51
This function expects a complete introspection result. Don't forget to check the
52
52
"errors" field of a server response before calling this function.
53
53
"""
54
+ if not isinstance (introspection , dict ) or not isinstance (
55
+ introspection .get ("__schema" ), dict
56
+ ):
57
+ raise TypeError (
58
+ "Invalid or incomplete introspection result. Ensure that you"
59
+ " are passing the 'data' attribute of an introspection response"
60
+ " and no 'errors' were returned alongside: " + inspect (introspection )
61
+ )
62
+
54
63
# Get the schema from the introspection result.
55
64
schema_introspection = introspection ["__schema" ]
56
65
Original file line number Diff line number Diff line change @@ -487,6 +487,27 @@ def describe_throws_when_given_invalid_introspection():
487
487
"""
488
488
)
489
489
490
+ def throws_when_introspection_is_missing_schema_property ():
491
+ with raises (TypeError ) as exc_info :
492
+ # noinspection PyTypeChecker
493
+ build_client_schema (None ) # type: ignore
494
+
495
+ assert str (exc_info .value ) == (
496
+ "Invalid or incomplete introspection result. Ensure that you"
497
+ " are passing the 'data' attribute of an introspection response"
498
+ " and no 'errors' were returned alongside: None"
499
+ )
500
+
501
+ with raises (TypeError ) as exc_info :
502
+ # noinspection PyTypeChecker
503
+ build_client_schema ({}) # type: ignore
504
+
505
+ assert str (exc_info .value ) == (
506
+ "Invalid or incomplete introspection result. Ensure that you"
507
+ " are passing the 'data' attribute of an introspection response"
508
+ " and no 'errors' were returned alongside: {}"
509
+ )
510
+
490
511
def throws_when_referenced_unknown_type ():
491
512
introspection = introspection_from_schema (dummy_schema )
492
513
You can’t perform that action at this time.
0 commit comments