mirror of
https://github.com/ash-project/ash_graphql.git
synced 2024-09-19 21:03:09 +12:00
docs: add some more getting started docs
This commit is contained in:
parent
cbb3349636
commit
f8b93f7699
1 changed files with 39 additions and 1 deletions
|
@ -81,5 +81,43 @@ defmodule MyApp.Schema do
|
||||||
[Absinthe.Middleware.Dataloader | Absinthe.Plugin.defaults()]
|
[Absinthe.Middleware.Dataloader | Absinthe.Plugin.defaults()]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Connect your schema
|
||||||
|
|
||||||
|
### Using Plug
|
||||||
|
|
||||||
|
If you are unfamiliar with how plug works, this [guide](https://elixirschool.com/en/lessons/specifics/plug/#dependencies) will be helpful for understanding it. It also guides you through
|
||||||
|
adding plug to your application.
|
||||||
|
|
||||||
|
Then you can use a `Plug.Router` and [forward](https://hexdocs.pm/plug/Plug.Router.html#forward/2) to your plugs similar to how it is done for phoenix:
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
forward "/gql", Absinthe.Plug, schema: YourSchema
|
||||||
|
|
||||||
|
forward "/playground",
|
||||||
|
Absinthe.Plug.GraphiQL,
|
||||||
|
schema: YourSchema
|
||||||
|
interface: :playground
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using Phoenix
|
||||||
|
|
||||||
|
You will simply want to add some code to your router, like so:
|
||||||
|
|
||||||
|
You will also likely want to set up the "playground" for trying things out.
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
scope "/" do
|
||||||
|
forward "/gql", Absinthe.Plug, schema: YourSchema
|
||||||
|
|
||||||
|
forward "/playground",
|
||||||
|
Absinthe.Plug.GraphiQL,
|
||||||
|
schema: YourSchema
|
||||||
|
interface: :playground
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
If you started with `mix new ...` instead of `mix phx.new ...` and you want to
|
||||||
|
still use phoenix, the fastest path that way is typically to just create a new
|
||||||
|
phoenix application and copy your resources/config over.
|
||||||
|
|
Loading…
Reference in a new issue