How to use the ariadne.GraphQLMiddleware 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 / test_wsgi_middleware.py View on Github external
def server():
    return GraphQLMiddleware(None, type_defs=type_defs, resolvers=resolvers, path="/")
github mirumee / ariadne / tests / test_wsgi_middleware.py View on Github external
def test_initializing_middleware_without_path_raises_value_error():
    with pytest.raises(Exception) as excinfo:
        GraphQLMiddleware(None, type_defs=type_defs, resolvers={}, path="")

    assert isinstance(excinfo.value, ValueError)
    assert excinfo.value.args[0] == "path keyword argument can't be empty"
github mirumee / ariadne / tests / test_wsgi_middleware.py View on Github external
def test_app_exceptions_are_not_handled(app_mock):
    exception = Exception("Test exception")
    app_mock = Mock(side_effect=exception)
    middleware = GraphQLMiddleware(app_mock, type_defs=type_defs, resolvers={})
    middleware.handle_request = Mock()

    with pytest.raises(Exception) as excinfo:
        middleware({"PATH_INFO": "/"}, Mock())
    assert excinfo.value is exception
    assert not middleware.handle_request.called
github mirumee / ariadne / tests / wsgi_middleware / test_initialization.py View on Github external
def test_initializing_middleware_without_path_raises_value_error(type_defs):
    with pytest.raises(Exception) as excinfo:
        GraphQLMiddleware(None, type_defs=type_defs, resolvers={}, path="")

    assert isinstance(excinfo.value, ValueError)
    assert excinfo.value.args[0] == "path keyword argument can't be empty"
github mirumee / ariadne / tests / wsgi_middleware / test_initialization.py View on Github external
def test_initializing_middleware_without_app_raises_type_error(type_defs):
    with pytest.raises(Exception) as excinfo:
        GraphQLMiddleware(None, type_defs=type_defs, resolvers={})
    assert isinstance(excinfo.value, TypeError)
    assert excinfo.value.args[0] == (
        "can't set custom path on WSGI middleware without providing "
        "application callable as first argument"
github mirumee / ariadne / tests / wsgi_middleware / test_initialization.py View on Github external
def test_initializing_middleware_with_app_and_root_path_raises_value_error(
    app_mock, type_defs
):
    with pytest.raises(Exception) as excinfo:
        GraphQLMiddleware(app_mock, type_defs=type_defs, resolvers={}, path="/")
    assert isinstance(excinfo.value, ValueError)
    assert excinfo.value.args[0] == (
        "WSGI middleware can't use root path together with application callable"
    )
github mirumee / ariadne / tests / test_wsgi_middleware.py View on Github external
def test_initializing_middleware_without_app_raises_type_error():
    with pytest.raises(Exception) as excinfo:
        GraphQLMiddleware(None, type_defs=type_defs, resolvers={})
    assert isinstance(excinfo.value, TypeError)
    assert excinfo.value.args[0] == (
        "can't set custom path on WSGI middleware without providing "
        "application callable as first argument"
github mirumee / ariadne / tests / test_wsgi_middleware.py View on Github external
def test_initializing_middleware_with_app_and_root_path_raises_value_error(app_mock):
    with pytest.raises(Exception) as excinfo:
        GraphQLMiddleware(app_mock, type_defs=type_defs, resolvers={}, path="/")
    assert isinstance(excinfo.value, ValueError)
    assert excinfo.value.args[0] == (
        "WSGI middleware can't use root path together with application callable"
    )
github mirumee / ariadne / tests / wsgi_middleware / test_initialization.py View on Github external
def test_initializing_middleware_with_non_callable_app_raises_type_error(type_defs):
    with pytest.raises(Exception) as excinfo:
        GraphQLMiddleware(True, type_defs=type_defs, resolvers={}, path="/")
    assert isinstance(excinfo.value, TypeError)
    assert excinfo.value.args[0] == "first argument must be a callable or None"