I have a route where I want to implement a plug that will check my auth before GraphQL processing. My problem is that the plug is not being called.
My pipeline looks like this:
pipeline :api do
plug :accepts, ["json"]
plug DxAppRcWeb.CheckAuth
forward "/", Absinthe.Plug, schema: DxAppRcWeb.Schema
end
The plug looks like this:
defmodule DxAppRcWeb.CheckAuth do
import Plug.Conn
alias DxAppRc.Auth.MockCheckAuth
def init(_default), do: IO.puts("Auth Plug Init")
def call(conn, opts), do: check_auth(conn, opts)
def check_auth(conn, _opts) do
IO.puts("Calling Check Auth...")
auth_token = conn |> get_req_header("authorization")
IO.inspect(auth_token, label: "Auth Token")
validate_auth_token(conn, auth_token)
end
#... More business logic
end
There is no output indicating that the Plug has been initialized or is being called per call. Any thoughts/suggestions?