How to use the ariadne.wsgi.GraphQL 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_configuration.py View on Github external
def test_custom_root_value_is_passed_to_resolvers(schema):
    app = GraphQL(schema, root_value={"test": "TEST-ROOT"})
    _, result = app.execute_query({}, {"query": "{ testRoot }"})
    assert result == {"data": {"testRoot": "TEST-ROOT"}}
github mirumee / ariadne / tests / test_start_simple_server.py View on Github external
def test_type_defs_resolvers_host_and_ip_are_passed_to_graphql_middleware(
    middleware_make_simple_server_mock, schema
):
    start_simple_server(schema, host="0.0.0.0", port=4444)
    call = middleware_make_simple_server_mock.call_args[0]
    assert call[0] == "0.0.0.0"
    assert call[1] == 4444
    assert isinstance(call[2], GraphQL)
github mirumee / ariadne / tests / wsgi / test_query_execution.py View on Github external
def test_middlewares_and_extensions_are_combined_in_correct_order(schema):
    def test_middleware(next_fn, *args, **kwargs):
        value = next_fn(*args, **kwargs)
        return f"*{value}*"

    app = GraphQL(schema, extensions=[CustomExtension], middleware=[test_middleware])
    client = TestClient(app)
    response = client.post("/", json={"query": '{ hello(name: "BOB") }'})
    assert response.json() == {"data": {"hello": "=*Hello, BOB!*="}}
github mirumee / ariadne / tests / wsgi / test_configuration.py View on Github external
def test_error_formatter_is_called_with_debug_disabled_flag(schema):
    error_formatter = Mock(return_value=True)
    app = GraphQL(schema, debug=False, error_formatter=error_formatter)
    execute_failing_query(app)
    error_formatter.assert_called_once_with(ANY, False)
github mirumee / ariadne / tests / wsgi / test_configuration.py View on Github external
def test_custom_context_value_is_passed_to_resolvers(schema):
    app = GraphQL(schema, context_value={"test": "TEST-CONTEXT"})
    _, result = app.execute_query({}, {"query": "{ testContext }"})
    assert result == {"data": {"testContext": "TEST-CONTEXT"}}
github mirumee / ariadne / tests / wsgi / test_configuration.py View on Github external
def test_custom_context_value_function_result_is_passed_to_resolvers(schema):
    get_context_value = Mock(return_value={"test": "TEST-CONTEXT"})
    app = GraphQL(schema, context_value=get_context_value)
    _, result = app.execute_query({}, {"query": "{ testContext }"})
    assert result == {"data": {"testContext": "TEST-CONTEXT"}}
github mirumee / ariadne / tests / wsgi / test_simple_server.py View on Github external
def test_start_simple_server_from_inheriting_type_respects_inheritance(
    type_defs, resolvers, make_server
):
    class CustomGraphQL(GraphQL):
        pass

    schema = make_executable_schema(type_defs, resolvers)
    start_simple_server(schema, server_class=CustomGraphQL)
    make_server.assert_called_once()
    called_with_args = make_server.call_args[0]
    assert isinstance(called_with_args[2], CustomGraphQL)
github mirumee / ariadne / tests / wsgi / test_configuration.py View on Github external
def test_extension_from_option_are_passed_to_query_executor(schema):
    app = GraphQL(schema, extensions=[CustomExtension])
    client = TestClient(app)
    response = client.post("/", json={"query": '{ hello(name: "BOB") }'})
    assert response.json() == {"data": {"hello": "hello, bob!"}}
github mirumee / ariadne / tests / wsgi / test_configuration.py View on Github external
def test_custom_root_value_function_is_called_with_context_value(schema):
    get_root_value = Mock(return_value=True)
    app = GraphQL(
        schema, context_value={"test": "TEST-CONTEXT"}, root_value=get_root_value
    )
    app.execute_query({}, {"query": "{ status }"})
    get_root_value.assert_called_once_with({"test": "TEST-CONTEXT"}, ANY)
github mirumee / ariadne / tests / wsgi / test_configuration.py View on Github external
def test_default_logger_is_used_to_log_error_if_custom_is_not_set(schema, mocker):
    logging_mock = mocker.patch("ariadne.logger.logging")
    app = GraphQL(schema)
    execute_failing_query(app)
    logging_mock.getLogger.assert_called_once_with("ariadne")