I’m trying to use Absinthe 1.4, currently on the latest published betas, and the Apollo Phoenix channel client. Currently building a basic authentication system, and I see this debug output when I hit one of my mutations:
[info] JOIN "__absinthe__:control" to Absinthe.Phoenix.Channel
Transport: Phoenix.Transports.WebSocket (2.0.0)
Serializer: Phoenix.Transports.V2.WebSocketSerializer
Parameters: %{}
[info] Replied __absinthe__:control :ok
[debug] INCOMING "doc" on "__absinthe__:control" to Absinthe.Phoenix.Channel
Transport: Phoenix.Transports.WebSocket
Parameters: %{"operationName" => nil, "query" => "mutation ($email: String!, $username: String!, $password: String!) {\n signUp(email: $email, username: $username, password: $password) {\n token\n user {\n id\n username\n __typename\n }\n __typename\n }\n}\n", "variables" => %{"email" => "user@example.com", "password" => "[FILTERED]", "username" => "user"}}
[debug] ABSINTHE schema=AppWeb.API variables=%{"email" => "user@example.com", "password" => "[FILTERED]", "username" => "user"}
---
mutation ($email: String!, $username: String!, $password: String!) {
signUp(email: $email, username: $username, password: $password) {
token
user {
id
username
__typename
}
__typename
}
}
---
I have an IO.puts("here")
in my resolver, so that should trigger. Additionally, I should see Ecto debugging output. None of that appears, though.
What does this debugging output mean? Seems the mutation is getting parsed correctly, but it isn’t hitting the resolver. Here’s the mutation definition:
field :sign_up, non_null(:sign_in_payload) do
arg :username, non_null(:string)
arg :email, non_null(:string)
arg :password, non_null(:string)
resolve(&Accounts.sign_up_resolver/2)
end
Here’s my socket definition, which I assume is where the channel maps to my GraphQL API:
defmodule AppWeb.UserSocket do
use Phoenix.Socket
use Absinthe.Phoenix.Socket
## Channels
# channel "room:*", AppWeb.RoomChannel
## Transports
transport :websocket, Phoenix.Transports.WebSocket
# transport :longpoll, Phoenix.Transports.LongPoll
# Socket params are passed from the client and can
# be used to verify and authenticate a user. After
# verification, you can put default assigns into
# the socket that will be set for all channels, ie
#
# {:ok, assign(socket, :user_id, verified_user_id)}
#
# To deny connection, return `:error`.
#
# See `Phoenix.Token` documentation for examples in
# performing token verification on connect.
def connect(_params, socket) do
{:ok, assign(socket, :absinthe, %{schema: AppWeb.API})}
end
# Socket id's are topics that allow you to identify all sockets for a given user:
#
# def id(socket), do: "user_socket:#{socket.assigns.user_id}"
#
# Would allow you to broadcast a "disconnect" event and terminate
# all active sockets and channels for a given user:
#
# AppWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
#
# Returning `nil` makes this socket anonymous.
def id(_socket), do: nil
end
Thanks.