Skip to content

Commit

Permalink
fix: lint + ci
Browse files Browse the repository at this point in the history
  • Loading branch information
stillmatic committed Aug 13, 2023
1 parent c561015 commit ff4a36b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +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.
2 changes: 1 addition & 1 deletion strawberry/cli/commands/export_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def export_schema(
schema_text = print_schema(schema_symbol)

if output:
with open(output, "w") as file:
with Path.open(output, "w") as file:
file.write(schema_text)
typer.echo(f"Schema exported to {output}")
else:
Expand Down
17 changes: 17 additions & 0 deletions tests/cli/test_export_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,20 @@ 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)])

assert result.exit_code == 0
assert output.read_text() == (
"type Query {\n"
" user: User!\n"
"}\n"
"\n"
"type User {\n"
" name: String!\n"
" age: Int!\n"
"}"
)

0 comments on commit ff4a36b

Please sign in to comment.