{"id":13833581,"url":"https://github.com/absinthe-graphql/absinthe_graphql_ws","last_synced_at":"2025-12-12T00:27:12.190Z","repository":{"id":42076808,"uuid":"373953355","full_name":"absinthe-graphql/absinthe_graphql_ws","owner":"absinthe-graphql","description":"Add graphql-ws websocket transport for Absinthe","archived":false,"fork":false,"pushed_at":"2024-07-12T13:15:22.000Z","size":94,"stargazers_count":66,"open_issues_count":13,"forks_count":20,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-11-17T15:55:41.676Z","etag":null,"topics":["elixir","graphql"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/absinthe_graphql_ws/overview.html","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/absinthe-graphql.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-04T20:31:52.000Z","updated_at":"2024-10-17T23:20:29.000Z","dependencies_parsed_at":"2024-08-04T12:01:27.078Z","dependency_job_id":"7c7323a7-b076-4ab1-9c1b-09cd7f6ca908","html_url":"https://github.com/absinthe-graphql/absinthe_graphql_ws","commit_stats":{"total_commits":90,"total_committers":10,"mean_commits":9.0,"dds":0.2666666666666667,"last_synced_commit":"b98d3deb15febd856725f69b7a54c38e3b67ab3b"},"previous_names":["absinthe-graphql/absinthe_graphql_ws","geometerio/absinthe_graphql_ws"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/absinthe-graphql%2Fabsinthe_graphql_ws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/absinthe-graphql%2Fabsinthe_graphql_ws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/absinthe-graphql%2Fabsinthe_graphql_ws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/absinthe-graphql%2Fabsinthe_graphql_ws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/absinthe-graphql","download_url":"https://codeload.github.com/absinthe-graphql/absinthe_graphql_ws/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225601456,"owners_count":17494817,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","graphql"],"created_at":"2024-08-04T12:00:51.250Z","updated_at":"2025-12-12T00:27:12.136Z","avatar_url":"https://github.com/absinthe-graphql.png","language":"Elixir","funding_links":[],"categories":["Running the update","Elixir"],"sub_categories":["By Popularity"],"readme":"# AbsintheGraphqlWS\n\nAdds a websocket transport for the [GraphQL over WebSocket\nProtocol](https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md) to Absinthe running in\nPhoenix.\n\nSee the [hex docs](https://hexdocs.pm/absinthe_graphql_ws) for more information.\n\n## References\n\n- https://github.com/enisdenjo/graphql-ws\n- This project is heavily inspired by [subscriptions-transport-ws](https://github.com/maartenvanvliet/subscriptions-transport-ws)\n\n## Installation\n\nAdd `absinthe_graphql_ws` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:absinthe_graphql_ws, \"~\u003e 0.3\"}\n  ]\nend\n```\n\n## Usage\n\n### Using the websocket client\n\n```elixir\ndefmodule ExampleWeb.ApiClient do\n  use GenServer\n\n  alias Absinthe.GraphqlWS.Client\n\n  def start(endpoint) do\n    Client.start(endpoint)\n  end\n\n  def init(args) do\n    {:ok, args}\n  end\n\n  def stop(client) do\n    Client.close(client)\n  end\n\n  @gql \"\"\"\n  mutation ChangeSomething($id: String!) {\n    changeSomething(id: $id) {\n      id\n      name\n    }\n  }\n  \"\"\"\n  def change_something(client, thing_id) do\n    {:ok, body} = Client.query(client, @gql, id: thing_id)\n\n    case get_in(body, ~w[data changeSomething]) do\n      nil -\u003e {:error, get_in(body, ~w[errors])}\n      thing -\u003e {:ok, thing}\n    end\n  end\n\n  @gql \"\"\"\n  query GetSomething($id: UUID!) {\n    thing(id: $id) {\n      id\n      name\n    }\n  }\n  \"\"\"\n  def get_thing(client, thing_id) do\n    case Client.query(client, @gql, id: thing_id) do\n      {:ok, %{\"data\" =\u003e %{\"thing\" =\u003e nil}}} -\u003e\n        nil\n\n      {:ok, %{\"data\" =\u003e %{\"thing\" =\u003e result}}} -\u003e\n        {:ok, result}\n\n      {:ok, errors} when is_list(errors) -\u003e\n        nil\n    end\n  end\n\n  @gql \"\"\"\n  subscription ThingChanges($thingId: String!){\n    thingChanges(thingId: $projectId) {\n      id\n      name\n    }\n  }\n  \"\"\"\n  # handler is a pid for a process that implements `handle_info/4` as below\n  def thing_changes(client, thing_id: thing_id, handler: handler) do\n    Client.subscribe(client, @gql, %{thingId: thing_id}, handler)\n  end\nend\n```\n\nAn example of handle_info\n\n```elixir\n  @impl true\n  def handle_info({:subscription, _id, %{\"data\" =\u003e %{\"thingChanges\" =\u003e thing_changes}}}, %{assigns: %{thing: thing}} = socket) do\n    changes = thing_changes |\u003e Enum.find(\u0026(\u00261[\"id\"] == thing.id))\n    socket |\u003e do_cool_update(changes[\"things\"]) |\u003e noreply()\n  end\n```\n\n## Benchmarks\n\nBenchmarks live in the `benchmarks` directory, and can be run with `MIX_ENV=bench mix run\nbenchmarks/\u003cfile\u003e`.\n\n## Contributing\n\n- Pull requests that may be rebased are preferrable to merges or squashes.\n- Please **do not** increment the version number in pull requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabsinthe-graphql%2Fabsinthe_graphql_ws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabsinthe-graphql%2Fabsinthe_graphql_ws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabsinthe-graphql%2Fabsinthe_graphql_ws/lists"}