Francesco
Absinthe.plug.put_options for context overwrites previous context
Hello!
I have recently discovered that calling Absinthe.Plug.put_options , in my case to add some information to the context, actually overwrites whatever might have been set as the context before. I have two plugs for my router, one that auths and adds the user to the context, and another that adds a workspace ID to the context. I know I could just combine these plugs but that kind of defeats the point of plugs (modular parts of a pipeline).
Absinthe.Plug.put_options(conn, context: %{authenticated: true, current_user: user})
Absinthe.Plug.put_options(conn, context: %{workspace: current_workspace})
So the question is, is there any way that I could modify the context object instead of overwriting it? I’d be happy to just get the current context, merge the new options, and call put_options with the merged object but I can’t see a great way to get the current context. Only way I can see is to grab it from conn.private.absinthe but that doesn’t feel right.
Marked As Solved
benwilson512
@Francesco PR welcome for an update_options function. In the short term feel free to grab it from conn.private.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








