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 Aug 13, 2023
1 parent 17aa9d7 commit 0a62556
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/guides/schema-export.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ Alternatively, the `--output` option can be used:

```bash
strawberry export-schema package.module:schema --output schema.graphql
```
```
5 changes: 3 additions & 2 deletions strawberry/cli/commands/export_schema.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -34,4 +35,4 @@ def export_schema(
file.write(schema_text)
typer.echo(f"Schema exported to {output}")
else:
print(schema_text) # noqa: T201
print(schema_text) # noqa: T201
7 changes: 5 additions & 2 deletions tests/cli/test_export_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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() == (
Expand All @@ -83,4 +86,4 @@ def test_output_option(cli_app: Typer, cli_runner: CliRunner, tmp_path):
" name: String!\n"
" age: Int!\n"
"}"
)
)

0 comments on commit 0a62556

Please sign in to comment.