GithubHelp home page GithubHelp logo

rodrigues / absinthe_plug Goto Github PK

View Code? Open in Web Editor NEW

This project forked from absinthe-graphql/absinthe_plug

1.0 3.0 0.0 330 KB

Plug support for Absinthe, the GraphQL toolkit for Elixir

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

License: MIT License

Elixir 93.22% HTML 6.78%

absinthe_plug's Introduction

Absinthe Plug

Build StatusLicense

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.4.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. Jason and Poison work out of the box.

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

Usage

Basic Usage:

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

plug Absinthe.Plug,
  schema: MyAppWeb.Schema

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

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

forward "/api",
  to: Absinthe.Plug,
  init_opts: [schema: MyAppWeb.Schema]

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

Phoenix.Router

If you are using Phoenix.Router, forward expects different arguments:

Plug.Router

forward "/graphiql",
  to: Absinthe.Plug.GraphiQL,
  init_opts: [
    schema: MyAppWeb.Schema,
    interface: :simple
  ]

Phoenix.Router

forward "/graphiql",
  Absinthe.Plug.GraphiQL,
  schema: MyAppWeb.Schema,
  interface: :simple

For more information see Phoenix.Router.forward/4.

GraphiQL

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

forward "/graphiql",
  to: Absinthe.Plug.GraphiQL,
  init_opts: [schema: MyAppWeb.Schema]

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

Documentation

See HexDocs.

More Help

Related Projects

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

License

See LICENSE.md.

absinthe_plug's People

Contributors

avitex avatar benwilson512 avatar binaryseed avatar bruce avatar cesarandreu avatar craig-day avatar derrickreimer avatar eamontaaffe avatar fishcakez avatar jayjun avatar jfrolich avatar jparise avatar lnikkila avatar maartenvanvliet avatar matthewlehner avatar mbenatti avatar mgwidmann avatar mmmries avatar nitingupta910 avatar petejkim avatar rafaelgaspar avatar rphuber avatar scrogson avatar skosch avatar steffkes avatar tlvenn avatar uri avatar vsouza avatar yordis avatar yury-dymov avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.