We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
After the 0.135.0 release, invalid GraphQL queries are not logged as errors
## Describe the Bug
Before the 0.135.0 invalid queries were logged as errors. For example, given following schema:
```python
import strawberry

@strawberry.type
class Query:
    @strawberry.field
    def version(self) -> int:
        return 139


schema = strawberry.schema.Schema(query=Query)
```
When executing a query: `query { v }` the error will be logged:
```
Cannot query field 'v' on type 'Query'.

GraphQL request:1:9
1 | query { v }
  |         ^
Stack (most recent call last):
...
```
After the update to 0.135.0 the log is silent on this.

## System Information

 - Operating system: Fedora Linux 36
 - Strawberry version (if applicable): >=0.135.0


--- 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/schema/execute.py`
Content:
```
1 from asyncio import ensure_future
2 from inspect import isawaitable
3 from typing import (
4     Awaitable,
5     Callable,
6     Iterable,
7     List,
8     Optional,
9     Sequence,
10     Tuple,
11     Type,
12     Union,
13     cast,
14 )
15 
16 from graphql import (
17     ExecutionContext as GraphQLExecutionContext,
18     ExecutionResult as GraphQLExecutionResult,
19     GraphQLError,
20     GraphQLSchema,
21     execute as original_execute,
22     parse,
23 )
24 from graphql.language import DocumentNode
25 from graphql.validation import ASTValidationRule, validate
26 
27 from strawberry.extensions import Extension
28 from strawberry.extensions.runner import ExtensionsRunner
29 from strawberry.types import ExecutionContext, ExecutionResult
30 from strawberry.types.graphql import OperationType
31 
32 from .exceptions import InvalidOperationTypeError
33 
34 
35 def parse_document(query: str) -> DocumentNode:
36     return parse(query)
37 
38 
39 def validate_document(
40     schema: GraphQLSchema,
41     document: DocumentNode,
42     validation_rules: Tuple[Type[ASTValidationRule], ...],
43 ) -> List[GraphQLError]:
44     return validate(
45         schema,
46         document,
47         validation_rules,
48     )
49 
50 
51 def _run_validation(execution_context: ExecutionContext) -> None:
52     # Check if there are any validation rules or if validation has
53     # already been run by an extension
54     if len(execution_context.validation_rules) > 0 and execution_context.errors is None:
55         assert execution_context.graphql_document
56         execution_context.errors = validate_document(
57             execution_context.schema._schema,
58             execution_context.graphql_document,
59             execution_context.validation_rules,
60         )
61 
62 
63 async def execute(
64     schema: GraphQLSchema,
65     query: str,
66     *,
67     allowed_operation_types: Iterable[OperationType],
68     extensions: Sequence[Union[Type[Extension], Extension]],
69     execution_context: ExecutionContext,
70     execution_context_class: Optional[Type[GraphQLExecutionContext]] = None,
71     process_errors: Callable[[List[GraphQLError], Optional[ExecutionContext]], None],
72 ) -> ExecutionResult:
73     extensions_runner = ExtensionsRunner(
74         execution_context=execution_context,
75         extensions=list(extensions),
76     )
77 
78     async with extensions_runner.request():
79         # Note: In graphql-core the schema would be validated here but in
80         # Strawberry we are validating it at initialisation time instead
81 
82         async with extensions_runner.parsing():
83             try:
84                 if not execution_context.graphql_document:
85                     execution_context.graphql_document = parse_document(query)
86 
87             except GraphQLError as error:
88                 execution_context.errors = [error]
89                 return ExecutionResult(
90                     data=None,
91                     errors=[error],
92                     extensions=await extensions_runner.get_extensions_results(),
93                 )
94 
95             except Exception as error:  # pragma: no cover
96                 error = GraphQLError(str(error), original_error=error)
97 
98                 execution_context.errors = [error]
99                 return ExecutionResult(
100                     data=None,
101                     errors=[error],
102                     extensions=await extensions_runner.get_extensions_results(),
103                 )
104 
105         if execution_context.operation_type not in allowed_operation_types:
106             raise InvalidOperationTypeError(execution_context.operation_type)
107 
108         async with extensions_runner.validation():
109             _run_validation(execution_context)
110             if execution_context.errors:
111                 return ExecutionResult(data=None, errors=execution_context.errors)
112 
113         async with extensions_runner.executing():
114             if not execution_context.result:
115                 result = original_execute(
116                     schema,
117                     execution_context.graphql_document,
118                     root_value=execution_context.root_value,
119                     middleware=extensions_runner.as_middleware_manager(),
120                     variable_values=execution_context.variables,
121                     operation_name=execution_context.operation_name,
122                     context_value=execution_context.context,
123                     execution_context_class=execution_context_class,
124                 )
125 
126                 if isawaitable(result):
127                     result = await cast(Awaitable[GraphQLExecutionResult], result)
128 
129                 result = cast(GraphQLExecutionResult, result)
130                 execution_context.result = result
131                 # Also set errors on the execution_context so that it's easier
132                 # to access in extensions
133                 if result.errors:
134                     execution_context.errors = result.errors
135 
136                     # Run the `Schema.process_errors` function here before
137                     # extensions have a chance to modify them (see the MaskErrors
138                     # extension). That way we can log the original errors but
139                     # only return a sanitised version to the client.
140                     process_errors(result.errors, execution_context)
141 
142     return ExecutionResult(
143         data=execution_context.result.data,
144         errors=execution_context.result.errors,
145         extensions=await extensions_runner.get_extensions_results(),
146     )
147 
148 
149 def execute_sync(
150     schema: GraphQLSchema,
151     query: str,
152     *,
153     allowed_operation_types: Iterable[OperationType],
154     extensions: Sequence[Union[Type[Extension], Extension]],
155     execution_context: ExecutionContext,
156     execution_context_class: Optional[Type[GraphQLExecutionContext]] = None,
157     process_errors: Callable[[List[GraphQLError], Optional[ExecutionContext]], None],
158 ) -> ExecutionResult:
159     extensions_runner = ExtensionsRunner(
160         execution_context=execution_context,
161         extensions=list(extensions),
162     )
163 
164     with extensions_runner.request():
165         # Note: In graphql-core the schema would be validated here but in
166         # Strawberry we are validating it at initialisation time instead
167 
168         with extensions_runner.parsing():
169             try:
170                 if not execution_context.graphql_document:
171                     execution_context.graphql_document = parse_document(query)
172 
173             except GraphQLError as error:
174                 execution_context.errors = [error]
175                 return ExecutionResult(
176                     data=None,
177                     errors=[error],
178                     extensions=extensions_runner.get_extensions_results_sync(),
179                 )
180 
181             except Exception as error:  # pragma: no cover
182                 error = GraphQLError(str(error), original_error=error)
183 
184                 execution_context.errors = [error]
185                 return ExecutionResult(
186                     data=None,
187                     errors=[error],
188                     extensions=extensions_runner.get_extensions_results_sync(),
189                 )
190 
191         if execution_context.operation_type not in allowed_operation_types:
192             raise InvalidOperationTypeError(execution_context.operation_type)
193 
194         with extensions_runner.validation():
195             _run_validation(execution_context)
196             if execution_context.errors:
197                 return ExecutionResult(data=None, errors=execution_context.errors)
198 
199         with extensions_runner.executing():
200             if not execution_context.result:
201                 result = original_execute(
202                     schema,
203                     execution_context.graphql_document,
204                     root_value=execution_context.root_value,
205                     middleware=extensions_runner.as_middleware_manager(),
206                     variable_values=execution_context.variables,
207                     operation_name=execution_context.operation_name,
208                     context_value=execution_context.context,
209                     execution_context_class=execution_context_class,
210                 )
211 
212                 if isawaitable(result):
213                     result = cast(Awaitable[GraphQLExecutionResult], result)
214                     ensure_future(result).cancel()
215                     raise RuntimeError(
216                         "GraphQL execution failed to complete synchronously."
217                     )
218 
219                 result = cast(GraphQLExecutionResult, result)
220                 execution_context.result = result
221                 # Also set errors on the execution_context so that it's easier
222                 # to access in extensions
223                 if result.errors:
224                     execution_context.errors = result.errors
225 
226                     # Run the `Schema.process_errors` function here before
227                     # extensions have a chance to modify them (see the MaskErrors
228                     # extension). That way we can log the original errors but
229                     # only return a sanitised version to the client.
230                     process_errors(result.errors, execution_context)
231 
232     return ExecutionResult(
233         data=execution_context.result.data,
234         errors=execution_context.result.errors,
235         extensions=extensions_runner.get_extensions_results_sync(),
236     )
237
```
--- 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()

```

diff --git a/strawberry/schema/execute.py b/strawberry/schema/execute.py
--- a/strawberry/schema/execute.py
+++ b/strawberry/schema/execute.py
@@ -86,6 +86,7 @@
 
             except GraphQLError as error:
                 execution_context.errors = [error]
+                process_errors([error], execution_context)
                 return ExecutionResult(
                     data=None,
                     errors=[error],
@@ -96,6 +97,8 @@
                 error = GraphQLError(str(error), original_error=error)
 
                 execution_context.errors = [error]
+                process_errors([error], execution_context)
+
                 return ExecutionResult(
                     data=None,
                     errors=[error],
@@ -108,6 +111,7 @@
         async with extensions_runner.validation():
             _run_validation(execution_context)
             if execution_context.errors:
+                process_errors(execution_context.errors, execution_context)
                 return ExecutionResult(data=None, errors=execution_context.errors)
 
         async with extensions_runner.executing():
@@ -172,6 +176,7 @@
 
             except GraphQLError as error:
                 execution_context.errors = [error]
+                process_errors([error], execution_context)
                 return ExecutionResult(
                     data=None,
                     errors=[error],
@@ -182,6 +187,7 @@
                 error = GraphQLError(str(error), original_error=error)
 
                 execution_context.errors = [error]
+                process_errors([error], execution_context)
                 return ExecutionResult(
                     data=None,
                     errors=[error],
@@ -194,6 +200,7 @@
         with extensions_runner.validation():
             _run_validation(execution_context)
             if execution_context.errors:
+                process_errors(execution_context.errors, execution_context)
                 return ExecutionResult(data=None, errors=execution_context.errors)
 
         with extensions_runner.executing():

{"golden_diff": "diff --git a/strawberry/schema/execute.py b/strawberry/schema/execute.py\n--- a/strawberry/schema/execute.py\n+++ b/strawberry/schema/execute.py\n@@ -86,6 +86,7 @@\n \n             except GraphQLError as error:\n                 execution_context.errors = [error]\n+                process_errors([error], execution_context)\n                 return ExecutionResult(\n                     data=None,\n                     errors=[error],\n@@ -96,6 +97,8 @@\n                 error = GraphQLError(str(error), original_error=error)\n \n                 execution_context.errors = [error]\n+                process_errors([error], execution_context)\n+\n                 return ExecutionResult(\n                     data=None,\n                     errors=[error],\n@@ -108,6 +111,7 @@\n         async with extensions_runner.validation():\n             _run_validation(execution_context)\n             if execution_context.errors:\n+                process_errors(execution_context.errors, execution_context)\n                 return ExecutionResult(data=None, errors=execution_context.errors)\n \n         async with extensions_runner.executing():\n@@ -172,6 +176,7 @@\n \n             except GraphQLError as error:\n                 execution_context.errors = [error]\n+                process_errors([error], execution_context)\n                 return ExecutionResult(\n                     data=None,\n                     errors=[error],\n@@ -182,6 +187,7 @@\n                 error = GraphQLError(str(error), original_error=error)\n \n                 execution_context.errors = [error]\n+                process_errors([error], execution_context)\n                 return ExecutionResult(\n                     data=None,\n                     errors=[error],\n@@ -194,6 +200,7 @@\n         with extensions_runner.validation():\n             _run_validation(execution_context)\n             if execution_context.errors:\n+                process_errors(execution_context.errors, execution_context)\n                 return ExecutionResult(data=None, errors=execution_context.errors)\n \n         with extensions_runner.executing():\n", "issue": "After the 0.135.0 release, invalid GraphQL queries are not logged as errors\n## Describe the Bug\r\nBefore the 0.135.0 invalid queries were logged as errors. For example, given following schema:\r\n```python\r\nimport strawberry\r\n\r\n@strawberry.type\r\nclass Query:\r\n    @strawberry.field\r\n    def version(self) -> int:\r\n        return 139\r\n\r\n\r\nschema = strawberry.schema.Schema(query=Query)\r\n```\r\nWhen executing a query: `query { v }` the error will be logged:\r\n```\r\nCannot query field 'v' on type 'Query'.\r\n\r\nGraphQL request:1:9\r\n1 | query { v }\r\n  |         ^\r\nStack (most recent call last):\r\n...\r\n```\r\nAfter the update to 0.135.0 the log is silent on this.\r\n\r\n## System Information\r\n\r\n - Operating system: Fedora Linux 36\r\n - Strawberry version (if applicable): >=0.135.0\r\n\n", "before_files": [{"content": "from asyncio import ensure_future\nfrom inspect import isawaitable\nfrom typing import (\n    Awaitable,\n    Callable,\n    Iterable,\n    List,\n    Optional,\n    Sequence,\n    Tuple,\n    Type,\n    Union,\n    cast,\n)\n\nfrom graphql import (\n    ExecutionContext as GraphQLExecutionContext,\n    ExecutionResult as GraphQLExecutionResult,\n    GraphQLError,\n    GraphQLSchema,\n    execute as original_execute,\n    parse,\n)\nfrom graphql.language import DocumentNode\nfrom graphql.validation import ASTValidationRule, validate\n\nfrom strawberry.extensions import Extension\nfrom strawberry.extensions.runner import ExtensionsRunner\nfrom strawberry.types import ExecutionContext, ExecutionResult\nfrom strawberry.types.graphql import OperationType\n\nfrom .exceptions import InvalidOperationTypeError\n\n\ndef parse_document(query: str) -> DocumentNode:\n    return parse(query)\n\n\ndef validate_document(\n    schema: GraphQLSchema,\n    document: DocumentNode,\n    validation_rules: Tuple[Type[ASTValidationRule], ...],\n) -> List[GraphQLError]:\n    return validate(\n        schema,\n        document,\n        validation_rules,\n    )\n\n\ndef _run_validation(execution_context: ExecutionContext) -> None:\n    # Check if there are any validation rules or if validation has\n    # already been run by an extension\n    if len(execution_context.validation_rules) > 0 and execution_context.errors is None:\n        assert execution_context.graphql_document\n        execution_context.errors = validate_document(\n            execution_context.schema._schema,\n            execution_context.graphql_document,\n            execution_context.validation_rules,\n        )\n\n\nasync def execute(\n    schema: GraphQLSchema,\n    query: str,\n    *,\n    allowed_operation_types: Iterable[OperationType],\n    extensions: Sequence[Union[Type[Extension], Extension]],\n    execution_context: ExecutionContext,\n    execution_context_class: Optional[Type[GraphQLExecutionContext]] = None,\n    process_errors: Callable[[List[GraphQLError], Optional[ExecutionContext]], None],\n) -> ExecutionResult:\n    extensions_runner = ExtensionsRunner(\n        execution_context=execution_context,\n        extensions=list(extensions),\n    )\n\n    async with extensions_runner.request():\n        # Note: In graphql-core the schema would be validated here but in\n        # Strawberry we are validating it at initialisation time instead\n\n        async with extensions_runner.parsing():\n            try:\n                if not execution_context.graphql_document:\n                    execution_context.graphql_document = parse_document(query)\n\n            except GraphQLError as error:\n                execution_context.errors = [error]\n                return ExecutionResult(\n                    data=None,\n                    errors=[error],\n                    extensions=await extensions_runner.get_extensions_results(),\n                )\n\n            except Exception as error:  # pragma: no cover\n                error = GraphQLError(str(error), original_error=error)\n\n                execution_context.errors = [error]\n                return ExecutionResult(\n                    data=None,\n                    errors=[error],\n                    extensions=await extensions_runner.get_extensions_results(),\n                )\n\n        if execution_context.operation_type not in allowed_operation_types:\n            raise InvalidOperationTypeError(execution_context.operation_type)\n\n        async with extensions_runner.validation():\n            _run_validation(execution_context)\n            if execution_context.errors:\n                return ExecutionResult(data=None, errors=execution_context.errors)\n\n        async with extensions_runner.executing():\n            if not execution_context.result:\n                result = original_execute(\n                    schema,\n                    execution_context.graphql_document,\n                    root_value=execution_context.root_value,\n                    middleware=extensions_runner.as_middleware_manager(),\n                    variable_values=execution_context.variables,\n                    operation_name=execution_context.operation_name,\n                    context_value=execution_context.context,\n                    execution_context_class=execution_context_class,\n                )\n\n                if isawaitable(result):\n                    result = await cast(Awaitable[GraphQLExecutionResult], result)\n\n                result = cast(GraphQLExecutionResult, result)\n                execution_context.result = result\n                # Also set errors on the execution_context so that it's easier\n                # to access in extensions\n                if result.errors:\n                    execution_context.errors = result.errors\n\n                    # Run the `Schema.process_errors` function here before\n                    # extensions have a chance to modify them (see the MaskErrors\n                    # extension). That way we can log the original errors but\n                    # only return a sanitised version to the client.\n                    process_errors(result.errors, execution_context)\n\n    return ExecutionResult(\n        data=execution_context.result.data,\n        errors=execution_context.result.errors,\n        extensions=await extensions_runner.get_extensions_results(),\n    )\n\n\ndef execute_sync(\n    schema: GraphQLSchema,\n    query: str,\n    *,\n    allowed_operation_types: Iterable[OperationType],\n    extensions: Sequence[Union[Type[Extension], Extension]],\n    execution_context: ExecutionContext,\n    execution_context_class: Optional[Type[GraphQLExecutionContext]] = None,\n    process_errors: Callable[[List[GraphQLError], Optional[ExecutionContext]], None],\n) -> ExecutionResult:\n    extensions_runner = ExtensionsRunner(\n        execution_context=execution_context,\n        extensions=list(extensions),\n    )\n\n    with extensions_runner.request():\n        # Note: In graphql-core the schema would be validated here but in\n        # Strawberry we are validating it at initialisation time instead\n\n        with extensions_runner.parsing():\n            try:\n                if not execution_context.graphql_document:\n                    execution_context.graphql_document = parse_document(query)\n\n            except GraphQLError as error:\n                execution_context.errors = [error]\n                return ExecutionResult(\n                    data=None,\n                    errors=[error],\n                    extensions=extensions_runner.get_extensions_results_sync(),\n                )\n\n            except Exception as error:  # pragma: no cover\n                error = GraphQLError(str(error), original_error=error)\n\n                execution_context.errors = [error]\n                return ExecutionResult(\n                    data=None,\n                    errors=[error],\n                    extensions=extensions_runner.get_extensions_results_sync(),\n                )\n\n        if execution_context.operation_type not in allowed_operation_types:\n            raise InvalidOperationTypeError(execution_context.operation_type)\n\n        with extensions_runner.validation():\n            _run_validation(execution_context)\n            if execution_context.errors:\n                return ExecutionResult(data=None, errors=execution_context.errors)\n\n        with extensions_runner.executing():\n            if not execution_context.result:\n                result = original_execute(\n                    schema,\n                    execution_context.graphql_document,\n                    root_value=execution_context.root_value,\n                    middleware=extensions_runner.as_middleware_manager(),\n                    variable_values=execution_context.variables,\n                    operation_name=execution_context.operation_name,\n                    context_value=execution_context.context,\n                    execution_context_class=execution_context_class,\n                )\n\n                if isawaitable(result):\n                    result = cast(Awaitable[GraphQLExecutionResult], result)\n                    ensure_future(result).cancel()\n                    raise RuntimeError(\n                        \"GraphQL execution failed to complete synchronously.\"\n                    )\n\n                result = cast(GraphQLExecutionResult, result)\n                execution_context.result = result\n                # Also set errors on the execution_context so that it's easier\n                # to access in extensions\n                if result.errors:\n                    execution_context.errors = result.errors\n\n                    # Run the `Schema.process_errors` function here before\n                    # extensions have a chance to modify them (see the MaskErrors\n                    # extension). That way we can log the original errors but\n                    # only return a sanitised version to the client.\n                    process_errors(result.errors, execution_context)\n\n    return ExecutionResult(\n        data=execution_context.result.data,\n        errors=execution_context.result.errors,\n        extensions=extensions_runner.get_extensions_results_sync(),\n    )\n", "path": "strawberry/schema/execute.py"}], "after_files": [{"content": "from asyncio import ensure_future\nfrom inspect import isawaitable\nfrom typing import (\n    Awaitable,\n    Callable,\n    Iterable,\n    List,\n    Optional,\n    Sequence,\n    Tuple,\n    Type,\n    Union,\n    cast,\n)\n\nfrom graphql import (\n    ExecutionContext as GraphQLExecutionContext,\n    ExecutionResult as GraphQLExecutionResult,\n    GraphQLError,\n    GraphQLSchema,\n    execute as original_execute,\n    parse,\n)\nfrom graphql.language import DocumentNode\nfrom graphql.validation import ASTValidationRule, validate\n\nfrom strawberry.extensions import Extension\nfrom strawberry.extensions.runner import ExtensionsRunner\nfrom strawberry.types import ExecutionContext, ExecutionResult\nfrom strawberry.types.graphql import OperationType\n\nfrom .exceptions import InvalidOperationTypeError\n\n\ndef parse_document(query: str) -> DocumentNode:\n    return parse(query)\n\n\ndef validate_document(\n    schema: GraphQLSchema,\n    document: DocumentNode,\n    validation_rules: Tuple[Type[ASTValidationRule], ...],\n) -> List[GraphQLError]:\n    return validate(\n        schema,\n        document,\n        validation_rules,\n    )\n\n\ndef _run_validation(execution_context: ExecutionContext) -> None:\n    # Check if there are any validation rules or if validation has\n    # already been run by an extension\n    if len(execution_context.validation_rules) > 0 and execution_context.errors is None:\n        assert execution_context.graphql_document\n        execution_context.errors = validate_document(\n            execution_context.schema._schema,\n            execution_context.graphql_document,\n            execution_context.validation_rules,\n        )\n\n\nasync def execute(\n    schema: GraphQLSchema,\n    query: str,\n    *,\n    allowed_operation_types: Iterable[OperationType],\n    extensions: Sequence[Union[Type[Extension], Extension]],\n    execution_context: ExecutionContext,\n    execution_context_class: Optional[Type[GraphQLExecutionContext]] = None,\n    process_errors: Callable[[List[GraphQLError], Optional[ExecutionContext]], None],\n) -> ExecutionResult:\n    extensions_runner = ExtensionsRunner(\n        execution_context=execution_context,\n        extensions=list(extensions),\n    )\n\n    async with extensions_runner.request():\n        # Note: In graphql-core the schema would be validated here but in\n        # Strawberry we are validating it at initialisation time instead\n\n        async with extensions_runner.parsing():\n            try:\n                if not execution_context.graphql_document:\n                    execution_context.graphql_document = parse_document(query)\n\n            except GraphQLError as error:\n                execution_context.errors = [error]\n                process_errors([error], execution_context)\n                return ExecutionResult(\n                    data=None,\n                    errors=[error],\n                    extensions=await extensions_runner.get_extensions_results(),\n                )\n\n            except Exception as error:  # pragma: no cover\n                error = GraphQLError(str(error), original_error=error)\n\n                execution_context.errors = [error]\n                process_errors([error], execution_context)\n\n                return ExecutionResult(\n                    data=None,\n                    errors=[error],\n                    extensions=await extensions_runner.get_extensions_results(),\n                )\n\n        if execution_context.operation_type not in allowed_operation_types:\n            raise InvalidOperationTypeError(execution_context.operation_type)\n\n        async with extensions_runner.validation():\n            _run_validation(execution_context)\n            if execution_context.errors:\n                process_errors(execution_context.errors, execution_context)\n                return ExecutionResult(data=None, errors=execution_context.errors)\n\n        async with extensions_runner.executing():\n            if not execution_context.result:\n                result = original_execute(\n                    schema,\n                    execution_context.graphql_document,\n                    root_value=execution_context.root_value,\n                    middleware=extensions_runner.as_middleware_manager(),\n                    variable_values=execution_context.variables,\n                    operation_name=execution_context.operation_name,\n                    context_value=execution_context.context,\n                    execution_context_class=execution_context_class,\n                )\n\n                if isawaitable(result):\n                    result = await cast(Awaitable[GraphQLExecutionResult], result)\n\n                result = cast(GraphQLExecutionResult, result)\n                execution_context.result = result\n                # Also set errors on the execution_context so that it's easier\n                # to access in extensions\n                if result.errors:\n                    execution_context.errors = result.errors\n\n                    # Run the `Schema.process_errors` function here before\n                    # extensions have a chance to modify them (see the MaskErrors\n                    # extension). That way we can log the original errors but\n                    # only return a sanitised version to the client.\n                    process_errors(result.errors, execution_context)\n\n    return ExecutionResult(\n        data=execution_context.result.data,\n        errors=execution_context.result.errors,\n        extensions=await extensions_runner.get_extensions_results(),\n    )\n\n\ndef execute_sync(\n    schema: GraphQLSchema,\n    query: str,\n    *,\n    allowed_operation_types: Iterable[OperationType],\n    extensions: Sequence[Union[Type[Extension], Extension]],\n    execution_context: ExecutionContext,\n    execution_context_class: Optional[Type[GraphQLExecutionContext]] = None,\n    process_errors: Callable[[List[GraphQLError], Optional[ExecutionContext]], None],\n) -> ExecutionResult:\n    extensions_runner = ExtensionsRunner(\n        execution_context=execution_context,\n        extensions=list(extensions),\n    )\n\n    with extensions_runner.request():\n        # Note: In graphql-core the schema would be validated here but in\n        # Strawberry we are validating it at initialisation time instead\n\n        with extensions_runner.parsing():\n            try:\n                if not execution_context.graphql_document:\n                    execution_context.graphql_document = parse_document(query)\n\n            except GraphQLError as error:\n                execution_context.errors = [error]\n                process_errors([error], execution_context)\n                return ExecutionResult(\n                    data=None,\n                    errors=[error],\n                    extensions=extensions_runner.get_extensions_results_sync(),\n                )\n\n            except Exception as error:  # pragma: no cover\n                error = GraphQLError(str(error), original_error=error)\n\n                execution_context.errors = [error]\n                process_errors([error], execution_context)\n                return ExecutionResult(\n                    data=None,\n                    errors=[error],\n                    extensions=extensions_runner.get_extensions_results_sync(),\n                )\n\n        if execution_context.operation_type not in allowed_operation_types:\n            raise InvalidOperationTypeError(execution_context.operation_type)\n\n        with extensions_runner.validation():\n            _run_validation(execution_context)\n            if execution_context.errors:\n                process_errors(execution_context.errors, execution_context)\n                return ExecutionResult(data=None, errors=execution_context.errors)\n\n        with extensions_runner.executing():\n            if not execution_context.result:\n                result = original_execute(\n                    schema,\n                    execution_context.graphql_document,\n                    root_value=execution_context.root_value,\n                    middleware=extensions_runner.as_middleware_manager(),\n                    variable_values=execution_context.variables,\n                    operation_name=execution_context.operation_name,\n                    context_value=execution_context.context,\n                    execution_context_class=execution_context_class,\n                )\n\n                if isawaitable(result):\n                    result = cast(Awaitable[GraphQLExecutionResult], result)\n                    ensure_future(result).cancel()\n                    raise RuntimeError(\n                        \"GraphQL execution failed to complete synchronously.\"\n                    )\n\n                result = cast(GraphQLExecutionResult, result)\n                execution_context.result = result\n                # Also set errors on the execution_context so that it's easier\n                # to access in extensions\n                if result.errors:\n                    execution_context.errors = result.errors\n\n                    # Run the `Schema.process_errors` function here before\n                    # extensions have a chance to modify them (see the MaskErrors\n                    # extension). That way we can log the original errors but\n                    # only return a sanitised version to the client.\n                    process_errors(result.errors, execution_context)\n\n    return ExecutionResult(\n        data=execution_context.result.data,\n        errors=execution_context.result.errors,\n        extensions=extensions_runner.get_extensions_results_sync(),\n    )\n", "path": "strawberry/schema/execute.py"}]}