Created
February 13, 2018 03:39
-
-
Save bruce/391400090a2456bf8c364912ba6ad6b9 to your computer and use it in GitHub Desktop.
Forwarding to two Absinthe schemas, what I'm sure is just an ugly hack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule CoryWeb.Router do | |
use CoryWeb, :router | |
defmodule SchemaOnePlug do | |
def init(_), do: Absinthe.Plug.init(schema: CoryWeb.SchemaOne) | |
def call(conn, opts), do: Absinthe.Plug.call(conn, opts) | |
end | |
defmodule SchemaTwoPlug do | |
def init(_), do: Absinthe.Plug.init(schema: CoryWeb.SchemaTwo) | |
def call(conn, opts), do: Absinthe.Plug.call(conn, opts) | |
end | |
pipeline :graphql do | |
plug Plug.Parsers, | |
parsers: [:urlencoded, :multipart, :json, Absinthe.Plug.Parser], | |
json_decoder: Poison | |
end | |
scope "/one", as: :one do | |
pipe_through :graphql | |
forward "/", SchemaOnePlug | |
end | |
scope "/two", as: :two do | |
pipe_through :graphql | |
forward "/", SchemaTwoPlug | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment