#Creating two Absinthe endpoints

6 messages · Page 1 of 1 (latest)

tight imp
#

I have a graphql API that I'm trying to implement - one public facing and one private. In my router.ex file I thought I could do something like this:

pipeline :auth do
    plug :accepts, ["json"]
    forward "/", Absinthe.Plug, schema: DxAppRcWeb.AuthSchema
  end
  
  pipeline :api do
    plug :accepts, ["json"]
    forward "/", Absinthe.Plug, schema: DxAppRcWeb.Schema
  end

Unfortunately, I'm getting an error:

 Absinthe.Plug has already been forwarded to. A module can only be forwarded a single time

What's the right way to do this sort of thing?

sharp shadow
#
#

just make a wrapper plug for each additional time you want to forward

tight imp
#

Reopening this - I tried wrapping the endpoints with my own module and implemented like this:

  pipeline :auth do
    plug :accepts, ["json"]
    forward "/", DxAppRcWeb.AuthWrapper, schema: DxAppRcWeb.AuthSchema
  end

  pipeline :api do
    plug :accepts, ["json"]
    plug DxAppRcWeb.CheckAuth

    forward "/", Absinthe.Plug, schema: DxAppRcWeb.Schema
  end

Now, both the auth and api paths implement the same schema (the Auth Schema).

#

I can comment out the first pipeline, and the protected endpoint is called

#

Am I doing something obviously wonky?