Skip to content

Instantly share code, notes, and snippets.

@bruce
Created February 13, 2018 03:39
Show Gist options
  • Save bruce/391400090a2456bf8c364912ba6ad6b9 to your computer and use it in GitHub Desktop.
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
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