Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added export-schema command to Docs #546

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/guide/export-schema.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Export Schema

!!! info

The `export_schema` management command provided here is specifically designed for use with `strawberry_django`. The [default Strawberry export command](https://strawberry.rocks/docs/guides/schema-export) won't work with `strawberry_django` schemas because `strawberry_django` extends the base functionality of Strawberry to integrate with Django models and queries. This command ensures proper schema export functionality.

The `export_schema` management command allows you to export a GraphQL schema defined using the `strawberry_django` library. This command converts the schema definition to GraphQL schema definition language (SDL), which can then be saved to a file or printed to the console.

## Usage

To use the `export_schema` command, you need to specify the schema location(e.g., myapp.schema). Optionally, you can provide a file path to save the schema. If no path is provided, the schema will be printed to the console.

```sh
python manage.py export_schema <schema_location> --path <output_path>
```

### Arguments

- `<schema_location>`: The location of the schema module. This should be a dot-separated Python path (e.g., myapp.schema). For example, if your schema is located in the `schemas` directory in the `myapp` django app, you would use `myapp.schemas`.

### Options

- `--path <output_path>`: An optional argument specifying the file path where the schema should be saved. If not provided, the schema will be printed to standard output.
bellini666 marked this conversation as resolved.
Show resolved Hide resolved

## Example

Here's an example of how to use the export_schema command:

```sh
python manage.py export_schema myapp.schema --path=output/schema.graphql
```

In this example, the schema located at `myapp.schema` will be exported to the file `output/schema.graphql`.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ nav:
- guide/authentication.md
- guide/settings.md
- guide/unit-testing.md
- guide/export-schema.md
- Integrations:
- integrations/debug-toolbar.md
- integrations/guardian.md
Expand Down
Loading