jeroenvisser101 / absinthe_plug

Plug support for Absinthe, the GraphQL toolkit for Elixir

Home Page:https://hex.pm/packages/absinthe_plug

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Absinthe Plug

Build Status

Plug support for Absinthe, the GraphQL toolkit for Elixir.

Please see the website at http://absinthe-graphql.org.

Installation

Install from Hex.pm:

def deps do
  [{:absinthe_plug, "~> 1.3.0"}]
end

If using Elixir < 1.4 (or manually managing applications), make sure to add it to your applications configuration in mix.exs:

def application do
  [applications: [:absinthe_plug]]
end

Absinthe.Plug also requires a JSON codec. Poison works out of the box.

def deps do
  [
    ...,
    {:absinthe_plug, "~> 1.3.0"},
    {:poison, "~> 1.3.0"}
  ]
end

Usage

Basic Usage:

plug Plug.Parsers,
  parsers: [:urlencoded, :multipart, :json, Absinthe.Plug.Parser],
  pass: ["*/*"],
  json_decoder: Poison

plug Absinthe.Plug,
  schema: MyApp.Schema

If you want only Absinthe.Plug to serve a particular route, configure your router like:

plug Plug.Parsers,
  parsers: [:urlencoded, :multipart, :json, Absinthe.Plug.Parser],
  pass: ["*/*"],
  json_decoder: Poison

forward "/api", Absinthe.Plug,
  schema: MyApp.Schema

For more information, see the API documentation for Absinthe.Plug.

GraphiQL

To add support for a GraphiQL interface, add a configuration for Absinthe.Plug.GraphiQL:

forward "/graphiql",
  Absinthe.Plug.GraphiQL,
  schema: MyApp.Schema,

See the API documentation for Absinthe.Plug.GraphiQL for more information.

More Help

Related Projects

See the project list at http://absinthe-graphql.org/projects.

License

See LICENSE.

About

Plug support for Absinthe, the GraphQL toolkit for Elixir

https://hex.pm/packages/absinthe_plug

License:Other


Languages

Language:Elixir 94.1%Language:HTML 5.9%