How to use the ariadne.constants.HTTP_STATUS_400_BAD_REQUEST function in ariadne

To help you get started, we’ve selected a few ariadne examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mirumee / ariadne / tests / wsgi / test_request_data_reading.py View on Github external
Content-Disposition: form-data; name="map"

{ "0": ["variables.file"] }
--------------------------cec8e8123c05ba25
Content-Disposition: form-data; name="0"; filename="test.txt"
Content-Type: text/plain

test

--------------------------cec8e8123c05ba25--
    """.strip()

    request = create_multipart_request(data)
    result = middleware(request, start_response)
    start_response.assert_called_once_with(
        HTTP_STATUS_400_BAD_REQUEST, error_response_headers
    )
    snapshot.assert_match(result)
github mirumee / ariadne / tests / wsgi / test_query_execution.py View on Github external
def test_attempt_execute_query_with_invalid_variables_returns_error_json(
    middleware,
    start_response,
    graphql_query_request_factory,
    graphql_response_headers,
    assert_json_response_equals_snapshot,
):
    request = graphql_query_request_factory(query=complex_query, variables="invalid")
    result = middleware(request, start_response)
    start_response.assert_called_once_with(
        HTTP_STATUS_400_BAD_REQUEST, graphql_response_headers
    )
    assert_json_response_equals_snapshot(result)
github mirumee / ariadne / tests / wsgi / test_request_data_reading.py View on Github external
Content-Disposition: form-data; name="map"

not a json
--------------------------cec8e8123c05ba25
Content-Disposition: form-data; name="0"; filename="test.txt"
Content-Type: text/plain

test

--------------------------cec8e8123c05ba25--
    """.strip()

    request = create_multipart_request(data)
    result = middleware(request, start_response)
    start_response.assert_called_once_with(
        HTTP_STATUS_400_BAD_REQUEST, error_response_headers
    )
    snapshot.assert_match(result)
github mirumee / ariadne / tests / wsgi / test_query_execution.py View on Github external
def test_attempt_execute_query_without_query_entry_returns_error_json(
    middleware,
    start_response,
    graphql_query_request_factory,
    graphql_response_headers,
    assert_json_response_equals_snapshot,
):
    request = graphql_query_request_factory(variables=variables)
    result = middleware(request, start_response)
    start_response.assert_called_once_with(
        HTTP_STATUS_400_BAD_REQUEST, graphql_response_headers
    )
    assert_json_response_equals_snapshot(result)
github mirumee / ariadne / ariadne / wsgi.py View on Github external
def return_response_from_result(
        self, start_response: Callable, result: GraphQLResult
    ) -> List[bytes]:
        success, response = result
        status_str = HTTP_STATUS_200_OK if success else HTTP_STATUS_400_BAD_REQUEST
        start_response(status_str, [("Content-Type", CONTENT_TYPE_JSON)])
        return [json.dumps(response).encode("utf-8")]
github mirumee / ariadne / ariadne / wsgi.py View on Github external
def handle_graphql_error(
        self, error: GraphQLError, start_response: Callable
    ) -> List[bytes]:
        start_response(
            HTTP_STATUS_400_BAD_REQUEST, [("Content-Type", CONTENT_TYPE_JSON)]
        )
        error_json = {"errors": [{"message": error.message}]}
        return [json.dumps(error_json).encode("utf-8")]
github mirumee / ariadne / ariadne / wsgi.py View on Github external
def return_response_from_result(
        self, start_response: Callable, result: GraphQLResult
    ) -> List[bytes]:
        success, response = result
        status_str = HTTP_STATUS_200_OK if success else HTTP_STATUS_400_BAD_REQUEST
        start_response(status_str, [("Content-Type", CONTENT_TYPE_JSON)])
        return [json.dumps(response).encode("utf-8")]
github mirumee / ariadne / ariadne / wsgi.py View on Github external
def handle_graphql_error(
        self, error: GraphQLError, start_response: Callable
    ) -> List[bytes]:
        start_response(
            HTTP_STATUS_400_BAD_REQUEST, [("Content-Type", CONTENT_TYPE_JSON)]
        )
        error_json = {"errors": [{"message": error.message}]}
        return [json.dumps(error_json).encode("utf-8")]