Get IP with Absinthe

Hello,
In a resolver (phoenix) I want to use “conn”. (I want to get the IP address)
How should I do that?

def vote(params, _info) do
    comment = Blog.Post.get_comment!(iparams.id)
    comment 
    |> Ecto.Changeset.change(ip: conn.remote_ip) # get the user IP??
    |> Repo.update
  end

Check out https://github.com/absinthe-graphql/absinthe/blob/master/guides/context-and-authentication.md

I think you need to create a Context Plug(halfway down) and add the user_ip into the context there.

2 Likes