tlux / graphql_ws_client Goto Github PK
View Code? Open in Web Editor NEWAn Elixir client for connecting with GraphQL over Websockets following the graphql-ws conventions
License: MIT License
An Elixir client for connecting with GraphQL over Websockets following the graphql-ws conventions
License: MIT License
At the moment, the iterator exits which probably is a bit error prone. Instead we should rather halt and log the error (the latter is something we are already doing)
We need to handle :gun_down
messages like these or else the Gun driver will fail in parse_message/2
:
{:gun_down, #PID<0.831.0>, :ws, :normal, [#Reference<0.2401964237.290979843.123374>]}
When the connection is terminated by the server, all listeners get notified that the socket has been closed. However, in some cases (for example if the client is running as part of the application supervision tree) it may be desirable to automatically restore all subscriptions when the connected is reopened. That means, we have to store all subscription queries and the associated listener processes in the client state and re-send all subscriptions right after the connection is restored.
Hence, I would like to introduce the :resubscribe_on_reconnect
config option.
We need to keep in mind, that graphq-ws sockets prohibit to reuse a subscription ID unless the old subscription was removed. So we should make sure that the old subscription is removed before resubscribing with the same ID.
18:04:32.606 [error] GenServer #PID<0.830.0> terminating
** (FunctionClauseError) no function clause matching in GraphQLWSClient.Driver.parse_message/2
(graphql_ws_client 0.1.1) lib/graphql_ws_client/driver.ex:82: GraphQLWSClient.Driver.parse_message(nil, {:gun_error, #PID<0.831.0>, #Reference<0.1050648357.2088501250.11223>, {:closed, :normal}})
(graphql_ws_client 0.1.1) lib/graphql_ws_client.ex:509: GraphQLWSClient.handle_info/2
(connection 1.1.0) lib/connection.ex:810: Connection.handle_async/3
(stdlib 4.3) gen_server.erl:1123: :gen_server.try_dispatch/4
(stdlib 4.3) gen_server.erl:1200: :gen_server.handle_msg/6
(stdlib 4.3) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: {:gun_error, #PID<0.831.0>, #Reference<0.1050648357.2088501250.11223>, {:closed, :normal}}
:resubscribe_on_reconnect
At the moment a query timeout will lead to reconnection. Instead we should remove the timed out query from the state, reply to the caller that the call timed out (%SocketError{cause: :timeout}
) and ignore any messages that arrive after the timeout. We should probably also explicitly unsubscribe after a read timeout by sending a complete
message to the socket.
Subscriptions in constrast should never time out.
In some cases users may want to have more control of the connect options, for instance when using SSL. We should allow passing those options to the gun driver.
Example: https://elixirforum.com/t/working-config-for-gun-websocket-client/46376
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.