prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  ASGI app broken with asyncio
  Our ASGI app is currently broken with async io stuff. The implementation I made needs a bit of love :) We might have a look at how Ariadne is doing this :)
  
  Here's a test that fails:
  
  ```python
  import typing
  
  import pytest
  
  import strawberry
  from starlette.testclient import TestClient
  from strawberry.asgi import GraphQL
  
  
  @pytest.fixture
  def async_schema():
      @strawberry.type
      class Query:
          @strawberry.field
          async def hello(self, info, name: typing.Optional[str] = None) -> str:
              return f"Hello {name or 'world'}"
  
      return strawberry.Schema(Query)
  
  
  @pytest.fixture
  def test_client(async_schema):
      app = GraphQL(async_schema)
  
      return TestClient(app)
  
  
  def test_simple_query(schema, test_client):
      response = test_client.post("/", json={"query": "{ hello }"})
  
      assert response.json() == {"data": {"hello": "Hello world"}}
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `strawberry/graphql.py`
  Content:
  ```
  1 import typing
  2 
  3 from graphql import (
  4     ExecutionResult,
  5     GraphQLError,
  6     GraphQLSchema,
  7     execute as graphql_excute,
  8     parse,
  9 )
  10 from graphql.subscription import subscribe as graphql_subscribe
  11 from graphql.type import validate_schema
  12 from graphql.validation import validate
  13 
  14 from .middleware import DirectivesMiddleware
  15 
  16 
  17 async def execute(
  18     schema: GraphQLSchema,
  19     query: str,
  20     context_value: typing.Any = None,
  21     variable_values: typing.Dict[str, typing.Any] = None,
  22     operation_name: str = None,
  23 ):
  24     schema_validation_errors = validate_schema(schema)
  25     if schema_validation_errors:
  26         return ExecutionResult(data=None, errors=schema_validation_errors)
  27 
  28     try:
  29         document = parse(query)
  30     except GraphQLError as error:
  31         return ExecutionResult(data=None, errors=[error])
  32     except Exception as error:
  33         error = GraphQLError(str(error), original_error=error)
  34         return ExecutionResult(data=None, errors=[error])
  35 
  36     validation_errors = validate(schema, document)
  37 
  38     if validation_errors:
  39         return ExecutionResult(data=None, errors=validation_errors)
  40 
  41     return graphql_excute(
  42         schema,
  43         parse(query),
  44         middleware=[DirectivesMiddleware()],
  45         variable_values=variable_values,
  46         operation_name=operation_name,
  47         context_value=context_value,
  48     )
  49 
  50 
  51 async def subscribe(
  52     schema: GraphQLSchema,
  53     query: str,
  54     root_value: typing.Any = None,
  55     context_value: typing.Any = None,
  56     variable_values: typing.Dict[str, typing.Any] = None,
  57     operation_name: str = None,
  58 ) -> typing.Union[typing.AsyncIterator[ExecutionResult], ExecutionResult]:
  59     document = parse(query)
  60 
  61     return await graphql_subscribe(
  62         schema=schema,
  63         document=document,
  64         root_value=root_value,
  65         context_value=context_value,
  66         variable_values=variable_values,
  67         operation_name=operation_name,
  68     )
  69
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/strawberry/graphql.py b/strawberry/graphql.py
  --- a/strawberry/graphql.py
  +++ b/strawberry/graphql.py
  @@ -1,4 +1,5 @@
   import typing
  +from inspect import isawaitable
   
   from graphql import (
       ExecutionResult,
  @@ -38,7 +39,7 @@
       if validation_errors:
           return ExecutionResult(data=None, errors=validation_errors)
   
  -    return graphql_excute(
  +    result = graphql_excute(
           schema,
           parse(query),
           middleware=[DirectivesMiddleware()],
  @@ -46,6 +47,9 @@
           operation_name=operation_name,
           context_value=context_value,
       )
  +    if isawaitable(result):
  +        result = await typing.cast(typing.Awaitable[ExecutionResult], result)
  +    return result
   
   
   async def subscribe(
  
verification_info: {"golden_diff": "diff --git a/strawberry/graphql.py b/strawberry/graphql.py\n--- a/strawberry/graphql.py\n+++ b/strawberry/graphql.py\n@@ -1,4 +1,5 @@\n import typing\n+from inspect import isawaitable\n \n from graphql import (\n     ExecutionResult,\n@@ -38,7 +39,7 @@\n     if validation_errors:\n         return ExecutionResult(data=None, errors=validation_errors)\n \n-    return graphql_excute(\n+    result = graphql_excute(\n         schema,\n         parse(query),\n         middleware=[DirectivesMiddleware()],\n@@ -46,6 +47,9 @@\n         operation_name=operation_name,\n         context_value=context_value,\n     )\n+    if isawaitable(result):\n+        result = await typing.cast(typing.Awaitable[ExecutionResult], result)\n+    return result\n \n \n async def subscribe(\n", "issue": "ASGI app broken with asyncio\nOur ASGI app is currently broken with async io stuff. The implementation I made needs a bit of love :) We might have a look at how Ariadne is doing this :)\r\n\r\nHere's a test that fails:\r\n\r\n```python\r\nimport typing\r\n\r\nimport pytest\r\n\r\nimport strawberry\r\nfrom starlette.testclient import TestClient\r\nfrom strawberry.asgi import GraphQL\r\n\r\n\r\n@pytest.fixture\r\ndef async_schema():\r\n    @strawberry.type\r\n    class Query:\r\n        @strawberry.field\r\n        async def hello(self, info, name: typing.Optional[str] = None) -> str:\r\n            return f\"Hello {name or 'world'}\"\r\n\r\n    return strawberry.Schema(Query)\r\n\r\n\r\n@pytest.fixture\r\ndef test_client(async_schema):\r\n    app = GraphQL(async_schema)\r\n\r\n    return TestClient(app)\r\n\r\n\r\ndef test_simple_query(schema, test_client):\r\n    response = test_client.post(\"/\", json={\"query\": \"{ hello }\"})\r\n\r\n    assert response.json() == {\"data\": {\"hello\": \"Hello world\"}}\r\n```\n", "before_files": [{"content": "import typing\n\nfrom graphql import (\n    ExecutionResult,\n    GraphQLError,\n    GraphQLSchema,\n    execute as graphql_excute,\n    parse,\n)\nfrom graphql.subscription import subscribe as graphql_subscribe\nfrom graphql.type import validate_schema\nfrom graphql.validation import validate\n\nfrom .middleware import DirectivesMiddleware\n\n\nasync def execute(\n    schema: GraphQLSchema,\n    query: str,\n    context_value: typing.Any = None,\n    variable_values: typing.Dict[str, typing.Any] = None,\n    operation_name: str = None,\n):\n    schema_validation_errors = validate_schema(schema)\n    if schema_validation_errors:\n        return ExecutionResult(data=None, errors=schema_validation_errors)\n\n    try:\n        document = parse(query)\n    except GraphQLError as error:\n        return ExecutionResult(data=None, errors=[error])\n    except Exception as error:\n        error = GraphQLError(str(error), original_error=error)\n        return ExecutionResult(data=None, errors=[error])\n\n    validation_errors = validate(schema, document)\n\n    if validation_errors:\n        return ExecutionResult(data=None, errors=validation_errors)\n\n    return graphql_excute(\n        schema,\n        parse(query),\n        middleware=[DirectivesMiddleware()],\n        variable_values=variable_values,\n        operation_name=operation_name,\n        context_value=context_value,\n    )\n\n\nasync def subscribe(\n    schema: GraphQLSchema,\n    query: str,\n    root_value: typing.Any = None,\n    context_value: typing.Any = None,\n    variable_values: typing.Dict[str, typing.Any] = None,\n    operation_name: str = None,\n) -> typing.Union[typing.AsyncIterator[ExecutionResult], ExecutionResult]:\n    document = parse(query)\n\n    return await graphql_subscribe(\n        schema=schema,\n        document=document,\n        root_value=root_value,\n        context_value=context_value,\n        variable_values=variable_values,\n        operation_name=operation_name,\n    )\n", "path": "strawberry/graphql.py"}], "after_files": [{"content": "import typing\nfrom inspect import isawaitable\n\nfrom graphql import (\n    ExecutionResult,\n    GraphQLError,\n    GraphQLSchema,\n    execute as graphql_excute,\n    parse,\n)\nfrom graphql.subscription import subscribe as graphql_subscribe\nfrom graphql.type import validate_schema\nfrom graphql.validation import validate\n\nfrom .middleware import DirectivesMiddleware\n\n\nasync def execute(\n    schema: GraphQLSchema,\n    query: str,\n    context_value: typing.Any = None,\n    variable_values: typing.Dict[str, typing.Any] = None,\n    operation_name: str = None,\n):\n    schema_validation_errors = validate_schema(schema)\n    if schema_validation_errors:\n        return ExecutionResult(data=None, errors=schema_validation_errors)\n\n    try:\n        document = parse(query)\n    except GraphQLError as error:\n        return ExecutionResult(data=None, errors=[error])\n    except Exception as error:\n        error = GraphQLError(str(error), original_error=error)\n        return ExecutionResult(data=None, errors=[error])\n\n    validation_errors = validate(schema, document)\n\n    if validation_errors:\n        return ExecutionResult(data=None, errors=validation_errors)\n\n    result = graphql_excute(\n        schema,\n        parse(query),\n        middleware=[DirectivesMiddleware()],\n        variable_values=variable_values,\n        operation_name=operation_name,\n        context_value=context_value,\n    )\n    if isawaitable(result):\n        result = await typing.cast(typing.Awaitable[ExecutionResult], result)\n    return result\n\n\nasync def subscribe(\n    schema: GraphQLSchema,\n    query: str,\n    root_value: typing.Any = None,\n    context_value: typing.Any = None,\n    variable_values: typing.Dict[str, typing.Any] = None,\n    operation_name: str = None,\n) -> typing.Union[typing.AsyncIterator[ExecutionResult], ExecutionResult]:\n    document = parse(query)\n\n    return await graphql_subscribe(\n        schema=schema,\n        document=document,\n        root_value=root_value,\n        context_value=context_value,\n        variable_values=variable_values,\n        operation_name=operation_name,\n    )\n", "path": "strawberry/graphql.py"}]}