From 9b289297ea232da3fc1fc7d04326dd71209ca8c1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 13 Aug 2023 17:19:39 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- RELEASE.md | 2 +- docs/guides/schema-export.md | 2 +- strawberry/cli/commands/export_schema.py | 5 +++-- tests/cli/test_export_schema.py | 7 +++++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 2bd434b93d..d35e3c8702 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,3 +1,3 @@ Release type: minor -Adds a new flag to `export-schema` command, `--output`, which allows the user to specify the output file. If unset (current behavior), the command will continue to print to stdout. \ No newline at end of file +Adds a new flag to `export-schema` command, `--output`, which allows the user to specify the output file. If unset (current behavior), the command will continue to print to stdout. diff --git a/docs/guides/schema-export.md b/docs/guides/schema-export.md index 8f364f64b0..74e3fc6fe3 100644 --- a/docs/guides/schema-export.md +++ b/docs/guides/schema-export.md @@ -30,4 +30,4 @@ Alternatively, the `--output` option can be used: ```bash strawberry export-schema package.module:schema --output schema.graphql -``` \ No newline at end of file +``` diff --git a/strawberry/cli/commands/export_schema.py b/strawberry/cli/commands/export_schema.py index 7daaed8e9b..483fe4eb0b 100644 --- a/strawberry/cli/commands/export_schema.py +++ b/strawberry/cli/commands/export_schema.py @@ -1,6 +1,7 @@ -import typer from pathlib import Path +import typer + from strawberry.cli.app import app from strawberry.cli.utils import load_schema from strawberry.printer import print_schema @@ -34,4 +35,4 @@ def export_schema( file.write(schema_text) typer.echo(f"Schema exported to {output}") else: - print(schema_text) # noqa: T201 \ No newline at end of file + print(schema_text) # noqa: T201 diff --git a/tests/cli/test_export_schema.py b/tests/cli/test_export_schema.py index 418f0bd486..b1e46fd338 100644 --- a/tests/cli/test_export_schema.py +++ b/tests/cli/test_export_schema.py @@ -68,10 +68,13 @@ def test_invalid_schema_instance(cli_app: Typer, cli_runner: CliRunner): assert result.exit_code == 2 assert expected_error in result.stdout.replace("\n", "") + def test_output_option(cli_app: Typer, cli_runner: CliRunner, tmp_path): selector = "tests.fixtures.sample_package.sample_module:schema" output = tmp_path / "schema.graphql" - result = cli_runner.invoke(cli_app, ["export-schema", selector, "--output", str(output)]) + result = cli_runner.invoke( + cli_app, ["export-schema", selector, "--output", str(output)] + ) assert result.exit_code == 0 assert output.read_text() == ( @@ -83,4 +86,4 @@ def test_output_option(cli_app: Typer, cli_runner: CliRunner, tmp_path): " name: String!\n" " age: Int!\n" "}" - ) \ No newline at end of file + )