ash_graphql/documentation/topics/sdl-file.md

34 lines
1.2 KiB
Markdown
Raw Normal View History

# Using the SDL File
2024-08-17 06:39:41 +12:00
By passing the `generate_sdl_file` to `use AshGraphql`, AshGraphql will generate
a schema file when you run `mix ash.codegen`. For example:
```elixir
use AshGraphql,
domains: [Domain1, Domain2],
generate_sdl_file: "priv/schema.graphql"
```
> ### Ensure your schema is up to date, gitignored, or not generated {: .info}
>
> We suggest first adding `mix ash.codegen --check` to your CI/CD pipeline to
> ensure the schema is always up-to-date. Alternatively you can add the file
> to your `.gitignore`, or you can remove the `generate_sdl_file` option to skip
> generating the file.
Some things that you can use this SDL file for:
## Documentation
The schema file itself represents your entire GraphQL API definition, and examining it can be very useful.
## Code Generation
You can use tools like [GraphQL codegen](https://the-guild.dev/graphql/codegen) to generate a client
for your GraphQL API.
## Validating Changes
Use the SDL file to check for breaking changes in your schema, especially if you are exposing a public API.
A plug and play github action for this can be found here: https://the-guild.dev/graphql/inspector/docs/products/action