File tree Expand file tree Collapse file tree
src/hypothesis_graphql/_strategies Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88def query (schema : str ) -> st .SearchStrategy :
99 parsed_schema = graphql .build_schema (schema )
1010 if parsed_schema .query_type is None :
11- raise ValueError
11+ raise ValueError ( "Query type is not defined in the schema" )
1212 return get_strategy_for_type (parsed_schema .query_type ).map (make_query ).map (graphql .print_ast )
1313
1414
Original file line number Diff line number Diff line change 11import graphql
2+ import pytest
23from hypothesis import given
34
45import hypothesis_graphql .strategies as gql_st
@@ -26,3 +27,11 @@ def test(query):
2627 graphql .parse (query )
2728
2829 test ()
30+
31+
32+ def test_missing_query ():
33+ schema = """type Author {
34+ name: String
35+ }"""
36+ with pytest .raises (ValueError , match = "Query type is not defined in the schema" ):
37+ gql_st .query (schema )
You can’t perform that action at this time.
0 commit comments