This package integrates Absinthe subscriptions with Phoenix, so that you can use subscriptions via websockets.
For getting started guides on subscriptions see: https://hexdocs.pm/absinthe/subscriptions.html
For getting started guides on server side rendering see: https://hexdocs.pm/absinthe/subscriptions.html
Install from Hex.pm:
For Phoenix 1.4, see the v1.5 branch: https://github.com/absinthe-graphql/absinthe_phoenix/tree/v1.5
def deps do
[
{:absinthe_phoenix, "~> 2.0.0"}
]
endNote: Absinthe.Phoenix requires Elixir 1.11 or higher.
See CHANGELOG for upgrade steps between versions.
You may want to look for the specific upgrade guide in the Absinthe documentation.
See "Usage," below, for basic usage information and links to specific resources.
- Absinthe.Phoenix hexdocs.
- For the tutorial, guides, and general information about Absinthe-related projects, see http://absinthe-graphql.org.
See the GitHub organization.
You need to have a working Phoenix PubSub configured. Here is what the default looks like if you create a new Phoenix project:
config :my_app, MyAppWeb.Endpoint,
# ... other config
pubsub_server: MyApp.PubSubIn your application supervisor add a line AFTER your existing endpoint supervision line:
[
# other children ...
MyAppWeb.Endpoint, # this line should already exist
{Absinthe.Subscription, pubsub: MyAppWeb.Endpoint}, # add this line
# other children ...
]Where MyAppWeb.Endpoint is the name of your application's phoenix endpoint.
Other options include:
- pool_size - Number of processes created to handle incoming messages concurrently on the current node. Default:
System.schedulers_online() * 2 - compress_registry? - Whether the underlying registry should be compressed. Default:
true - async - Whether the each process above should handle the message in-process (
false) or create a new process to do so (true). Default:true - registry_partition_strategy - Partition the registry by
:pidor by:key.:keyis only supported in Elixir 1.19 and up. Default::pid
In your MyAppWeb.Endpoint module add:
use Absinthe.Phoenix.EndpointIn your socket add:
use Absinthe.Phoenix.Socket,
schema: MyAppWeb.SchemaWhere MyAppWeb.Schema is the name of your Absinthe schema module.
That is all that's required for setup on the server.
For client side guidance see the guides.
From within GraphiQL: To use Absinthe.Phoenix from within GraphiQL, you need to tell GraphiQL about your websocket endpoint.
forward "/graphiql", Absinthe.Plug.GraphiQL,
schema: MyAppWeb.Schema,
socket: MyAppWeb.UserSocketThe project is under constant improvement by a growing list of
contributors, and your feedback is important. Please join us in Slack
(#absinthe-graphql under the Elixir Slack account) or the Elixir Forum
(tagged absinthe).
Please remember that all interactions in our official spaces follow our Code of Conduct.
Please follow contribution guide.
Copyright (c) 2016 Bruce Williams, Ben Wilson
Released under the MIT License, which can be found in LICENSE.md.