-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathrouter.ex
More file actions
30 lines (24 loc) · 798 Bytes
/
router.ex
File metadata and controls
30 lines (24 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
defmodule BlogWeb.Router do
use BlogWeb, :router
pipeline :api do
plug :accepts, ["json"]
plug BlogWeb.Context
end
scope "/api" do
pipe_through :api
forward "/graphiql", Absinthe.Plug.GraphiQL,
schema: BlogWeb.Schema,
json_codec: BlogWeb.JSON,
pipeline: {__MODULE__, :absinthe_pipeline}
forward "/", Absinthe.Plug,
schema: BlogWeb.Schema,
json_codec: BlogWeb.JSON,
pipeline: {__MODULE__, :absinthe_pipeline}
end
def absinthe_pipeline(config, pipeline_opts) do
pipeline_opts = Keyword.put(pipeline_opts, :result_phase, BlogWeb.OrdGraphQLResult)
config.schema_mod
|> Absinthe.Pipeline.for_document(pipeline_opts)
|> Absinthe.Pipeline.replace(Absinthe.Phase.Document.Result, BlogWeb.OrdGraphQLResult)
end
end