Add GraphQL methods and test

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Finish

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Fix tests

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-03-14 18:31:14 +01:00
parent 98b7618338
commit 6ca0b5f915
8 changed files with 192 additions and 10 deletions

View File

@@ -12,11 +12,17 @@ defmodule MobilizonWeb.Context do
end
def call(conn, _) do
with %User{} = user <- Guardian.Plug.current_resource(conn) do
put_private(conn, :absinthe, %{context: %{current_user: user}})
else
nil ->
conn
end
context = %{ip: to_string(:inet_parse.ntoa(conn.remote_ip))}
context =
case Guardian.Plug.current_resource(conn) do
%User{} = user ->
Map.put(context, :current_user, user)
nil ->
context
end
put_private(conn, :absinthe, %{context: context})
end
end