Absinthe.GraphqlWS.Util.assign_context
You're seeing just the function
assign_context
, go back to Absinthe.GraphqlWS.Util module for more information.
Adds key-value pairs into Absinthe context. This can be used in the Absinthe.GraphqlWS.Socket.handle_init/2
to assign keys/values to the current Absinthe context.
Examples
defmodule MySocket do
use Absinthe.GraphqlWS.Socket, schema: MySchema
def handle_init(%{"user_id" => user_id}) do
user = find_user(user_id)
socket = assign_context(socket, current_user: user)
%{:reply, :ok, {:text, Absinthe.GraphqlWS.Message.ConnectionAck.new()}, socket}
end
end
Same as assign_context/2
except one key-value pair is assigned.