@@ -196,6 +196,30 @@ async def test_missing_query(http_client: HttpClient):
196196 assert "No GraphQL query found in the request" in response .text
197197
198198
199+ @pytest .mark .parametrize (
200+ "not_stringified_json" ,
201+ [{"obj" : "ect" }, 0 , False , ["array" ]],
202+ )
203+ async def test_requests_with_invalid_query_parameter_are_rejected (
204+ http_client : HttpClient , not_stringified_json
205+ ):
206+ response = await http_client .query (
207+ query = not_stringified_json ,
208+ )
209+
210+ assert response .status_code == 400
211+ message = "The GraphQL operation's `query` must be a string or null, if provided."
212+
213+ if isinstance (http_client , ChaliceHttpClient ):
214+ # Our Chalice integration purposely wraps errors messages with a JSON object
215+ assert response .json == {
216+ "Code" : "BadRequestError" ,
217+ "Message" : message ,
218+ }
219+ else :
220+ assert response .data == message .encode ()
221+
222+
199223@pytest .mark .parametrize ("method" , ["get" , "post" ])
200224async def test_query_context (method : Literal ["get" , "post" ], http_client : HttpClient ):
201225 response = await http_client .query (
0 commit comments