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 + )