Skip to content
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
30 changes: 23 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,19 +482,35 @@ Note: This tutorial was updated on macOS 11.6.2.
end
```

22. add route for mounting the GraphiQL browser endpoint:
22. add routes for our GraphQL API and GraphiQL browser endpoints:

`lib/zero_phoenix_web/router.ex`:

replace

```elixir
scope "/graphiql" do
scope "/api", ZeroPhoenixWeb do
pipe_through :api
end
```

with

```
scope "/" do
pipe_through :api

if Mix.env() in [:dev, :test] do
forward "/graphiql",
Absinthe.Plug.GraphiQL,
schema: ZeroPhoenixWeb.Graphql.Schema,
json_codec: Jason,
interface: :playground
end

forward "/",
Absinthe.Plug.GraphiQL,
schema: ZeroPhoenixWeb.Graphql.Schema,
json_codec: Jason,
interface: :playground
forward "/graphql",
Absinthe.Plug,
schema: ZeroPhoenixWeb.Graphql.Schema
end
```

Expand Down
18 changes: 10 additions & 8 deletions lib/zero_phoenix_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ defmodule ZeroPhoenixWeb.Router do
scope "/" do
pipe_through :api

if Mix.env() in [:dev, :test] do
forward "/graphiql",
Absinthe.Plug.GraphiQL,
schema: ZeroPhoenixWeb.Graphql.Schema,
json_codec: Jason,
interface: :playground
end

forward "/graphql",
Absinthe.Plug,
schema: ZeroPhoenixWeb.Graphql.Schema

forward "/graphiql",
Absinthe.Plug.GraphiQL,
schema: ZeroPhoenixWeb.Graphql.Schema,
json_codec: Jason,
interface: :playground
Absinthe.Plug,
schema: ZeroPhoenixWeb.Graphql.Schema
end

# Enables LiveDashboard only for development
Expand Down