Absinthe overview - SolarisJapan/lunaris-wiki GitHub Wiki

Absinthe overview

Absinthe is graphql tool for Elixir http://absinthe-graphql.org/

Installation absinthe to Elixir/Phoenix app

defp deps do
    [
      {:phoenix, "~> 1.4.9"},
      {:phoenix_pubsub, "~> 1.1"},
      {:phoenix_ecto, "~> 4.0"},
      {:ecto_sql, "~> 3.1"},
      {:postgrex, ">= 0.0.0"},
      {:gettext, "~> 0.11"},
      {:jason, "~> 1.0"},
      {:plug_cowboy, "~> 2.0"},
      {:absinthe, "~> 1.4.0"},
      {:absinthe_plug, "~> 1.4.0"},
      {:absinthe_ecto, "~> 0.1.3"}    
  ]
end

Install deps

mix deps.get

Then then update the router.ex

scope "/api" do
  pipe_through :api
  
  forward("/graphql", Absinthe.Plug, schema: MyAppWeb.Graphql.Schema)

  if Mix.env() == :dev do
    forward("/graphiql", Absinthe.Plug.GraphiQL, schema: MyAppWebWeb.Graphql.Schema)
  end
end