Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 12, 2024
1 parent 6a5fc0c commit 9f285c7
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions strawberry/schema/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,45 +158,44 @@ async def execute(
) -> ExecutionResult | PreExecutionError:
try:
async with extensions_runner.operation():
# Note: In graphql-core the schema would be validated here but in
# Strawberry we are validating it at initialisation time instead

if errors := await _parse_and_validate_async(
execution_context, extensions_runner
):
return await _handle_execution_result(
execution_context, errors, extensions_runner, process_errors
)

assert execution_context.graphql_document
async with extensions_runner.executing():
if not execution_context.result:
result = await await_maybe(
original_execute(
schema,
execution_context.graphql_document,
root_value=execution_context.root_value,
middleware=middleware_manager,
variable_values=execution_context.variables,
operation_name=execution_context.operation_name,
context_value=execution_context.context,
execution_context_class=execution_context_class,
)
)
execution_context.result = result
else:
result = execution_context.result
# Also set errors on the execution_context so that it's easier
# to access in extensions
if result.errors:
execution_context.errors = result.errors
# Note: In graphql-core the schema would be validated here but in
# Strawberry we are validating it at initialisation time instead

# Run the `Schema.process_errors` function here before
# extensions have a chance to modify them (see the MaskErrors
# extension). That way we can log the original errors but
# only return a sanitised version to the client.
process_errors(result.errors, execution_context)
if errors := await _parse_and_validate_async(
execution_context, extensions_runner
):
return await _handle_execution_result(
execution_context, errors, extensions_runner, process_errors
)

assert execution_context.graphql_document
async with extensions_runner.executing():
if not execution_context.result:
result = await await_maybe(
original_execute(
schema,
execution_context.graphql_document,
root_value=execution_context.root_value,
middleware=middleware_manager,
variable_values=execution_context.variables,
operation_name=execution_context.operation_name,
context_value=execution_context.context,
execution_context_class=execution_context_class,
)
)
execution_context.result = result
else:
result = execution_context.result
# Also set errors on the execution_context so that it's easier
# to access in extensions
if result.errors:
execution_context.errors = result.errors

# Run the `Schema.process_errors` function here before
# extensions have a chance to modify them (see the MaskErrors
# extension). That way we can log the original errors but
# only return a sanitised version to the client.
process_errors(result.errors, execution_context)

except (MissingQueryError, InvalidOperationTypeError) as e:
raise e
Expand All @@ -212,6 +211,7 @@ async def execute(
execution_context, result, extensions_runner, process_errors
)


def execute_sync(
schema: GraphQLSchema,
*,
Expand Down

0 comments on commit 9f285c7

Please sign in to comment.