Thanks for your answer. To summarize:
My goal is to connect from a Swift App to my Elixir Ash Backend. I am using a playground to debug. I now tried it with Altair - it gives a lot of GraqhQL options.
(i did not check out Absinthe.Client - as this is not my use case)
Result of my debugging:
:playground: Works
Altair: Does not work
The difference in the log output is that with playground it logs the subscription. With Altair there is no such log (I marked it with THIS IS NOT LOGGED ON ALTAIR).
Debug Process
Branch: [Debug]
(GitHub - bastiW/my_subscription_app_sqlite at debug)
Start Server with mix phx.server
I added to my graphql_socket.ex
def connect(params, socket, connect_info) do
path = case connect_info[:uri] do
%URI{path: p} -> p
_ -> "unknown"
end
IO.puts("GraphqlSocket params #{inspect(params)}")
IO.puts("GraphqlSocket socket #{inspect(socket)}")
IO.puts("GraphqlSocket connected path: #{path}")
{:ok, socket}
end
Modification in endpoint.ex
socket "/ws/gql", MySubscriptionAppSqliteWeb.GraphqlSocket, websocket: [connect_info: [:uri]], longpoll: false
:Playground
Log output on server with web playground
GraphqlSocket params %{"vsn" => "2.0.0"}
GraphqlSocket socket %Phoenix.Socket{assigns: %{}, channel: nil, channel_pid: nil, endpoint: MySubscriptionAppSqliteWeb.Endpoint, handler: MySubscriptionAppSqliteWeb.GraphqlSocket, id: nil, joined: false, join_ref: nil, private: %{}, pubsub_server: MySubscriptionAppSqlite.PubSub, ref: nil, serializer: Phoenix.Socket.V2.JSONSerializer, topic: nil, transport: :websocket, transport_pid: nil}
GraphqlSocket connected path: /ws/gql/websocket
[info] CONNECTED TO MySubscriptionAppSqliteWeb.GraphqlSocket in 5ms
Transport: :websocket
Serializer: Phoenix.Socket.V2.JSONSerializer
Parameters: %{"vsn" => "2.0.0"}
[info] JOINED __absinthe__:control in 58µs
Parameters: %{}
[debug] ABSINTHE schema=MySubscriptionAppSqliteWeb.GraphqlSchema variables=%{}
---
// ---> THIS IS NOT LOGGED ON ALTAIR:
subscription PostCreated {
postChanged {
created {
id
text
text
}
}
}
---
[debug] -- Absinthe Phoenix Reply --
{:ok, %{subscriptionId: "__absinthe__:doc:NDBuu9SaWIecvz5i9JO1q8t8pVxZNpzmkO5ZKzdfHxw=:A604DB20983D4EF98C369B525464A8023C4EB34291F6CDAC41CB20E481D3B2B6"}}
----------------------------
Altair
On Altair there is no log of the subscription on the server.
GraphqlSocket params %{"vsn" => "2.0.0"}
GraphqlSocket socket %Phoenix.Socket{assigns: %{}, channel: nil, channel_pid: nil, endpoint: MySubscriptionAppSqliteWeb.Endpoint, handler: MySubscriptionAppSqliteWeb.GraphqlSocket, id: nil, joined: false, join_ref: nil, private: %{}, pubsub_server: MySubscriptionAppSqlite.PubSub, ref: nil, serializer: Phoenix.Socket.V2.JSONSerializer, topic: nil, transport: :websocket, transport_pid: nil}
GraphqlSocket connected path: /ws/gql/websocket
[info] CONNECTED TO MySubscriptionAppSqliteWeb.GraphqlSocket in 1ms
Transport: :websocket
Serializer: Phoenix.Socket.V2.JSONSerializer
Parameters: %{"vsn" => "2.0.0"}
// ---> Here no log anymore. It just reconnects again and agian