Skip to content

Commit

Permalink
chore: use pathlib
Browse files Browse the repository at this point in the history
  • Loading branch information
stillmatic committed Aug 12, 2023
1 parent dc167b6 commit c561015
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions strawberry/cli/commands/export_schema.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import typer
from pathlib import Path

from strawberry.cli.app import app
from strawberry.cli.utils import load_schema
Expand All @@ -18,19 +19,19 @@ def export_schema(
"Works the same as `--app-dir` in uvicorn."
),
),
output: str = typer.Option(
output: Path = typer.Option(
None,
"--output",
help="File to save the exported schema. If not provided, prints to console.",
),
) -> None:
schema_symbol = load_schema(schema, app_dir)

schema_text = print_schema(schema_symbol) # noqa: T201
schema_text = print_schema(schema_symbol)

if output:
with open(output, "w") as file:
file.write(schema_text)
typer.echo(f"Schema exported to {output}")
else:
print(schema_text)
print(schema_text) # noqa: T201

0 comments on commit c561015

Please sign in to comment.