Skip to content

Commit 44e00fc

Browse files
committed
build_client_schema: add test for missing standard scalar
Replicates graphql/graphql-js@72bd71e
1 parent b1a0c66 commit 44e00fc

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The current version 3.0.0a2 of GraphQL-core is up-to-date
1616
with GraphQL.js version 14.4.1.
1717

1818
All parts of the API are covered by an extensive test suite
19-
of currently 1906 unit tests.
19+
of currently 1907 unit tests.
2020

2121

2222
## Documentation

tests/utilities/test_build_client_schema.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,30 @@ def throws_when_referenced_unknown_type():
562562
" in order to build a client schema."
563563
)
564564

565+
def throws_when_missing_definition_for_one_of_the_standard_scalars():
566+
schema = build_schema(
567+
"""
568+
type Query {
569+
foo: Float
570+
}
571+
"""
572+
)
573+
introspection = introspection_from_schema(schema)
574+
introspection["__schema"]["types"] = [
575+
type_
576+
for type_ in introspection["__schema"]["types"]
577+
if type_["name"] != "Float"
578+
]
579+
580+
with raises(TypeError) as exc_info:
581+
build_client_schema(introspection)
582+
583+
assert str(exc_info.value).endswith(
584+
"Invalid or incomplete schema, unknown type: Float."
585+
" Ensure that a full introspection query is used"
586+
" in order to build a client schema."
587+
)
588+
565589
def throws_when_type_reference_is_missing_name():
566590
introspection = introspection_from_schema(dummy_schema)
567591

0 commit comments

Comments
 (0)