absinthe-subscriptions
Use when implementing real-time GraphQL subscriptions with Absinthe. Covers Phoenix channels, PubSub, and subscription patterns.
Best use case
absinthe-subscriptions is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Use when implementing real-time GraphQL subscriptions with Absinthe. Covers Phoenix channels, PubSub, and subscription patterns.
Teams using absinthe-subscriptions should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/absinthe-subscriptions/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How absinthe-subscriptions Compares
| Feature / Agent | absinthe-subscriptions | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Use when implementing real-time GraphQL subscriptions with Absinthe. Covers Phoenix channels, PubSub, and subscription patterns.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
SKILL.md Source
# Absinthe - Subscriptions
Guide to implementing real-time GraphQL subscriptions with Absinthe and Phoenix.
## Key Concepts
### Basic Setup
```elixir
# In your Phoenix endpoint
defmodule MyAppWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :my_app
use Absinthe.Phoenix.Endpoint
socket "/socket", MyAppWeb.UserSocket,
websocket: true,
longpoll: false
end
# Socket configuration
defmodule MyAppWeb.UserSocket do
use Phoenix.Socket
use Absinthe.Phoenix.Socket, schema: MyApp.Schema
def connect(params, socket, _connect_info) do
current_user = get_user_from_token(params["token"])
socket = Absinthe.Phoenix.Socket.put_options(socket,
context: %{current_user: current_user}
)
{:ok, socket}
end
def id(socket), do: "user_socket:#{socket.assigns.user_id}"
end
```
### Defining Subscriptions
```elixir
defmodule MyApp.Schema.Subscriptions do
use Absinthe.Schema.Notation
object :post_subscriptions do
field :post_created, :post do
config fn _args, _resolution ->
{:ok, topic: "posts"}
end
trigger :create_post, topic: fn _post ->
"posts"
end
end
field :post_updated, :post do
arg :id, non_null(:id)
config fn %{id: id}, _resolution ->
{:ok, topic: "post:#{id}"}
end
trigger :update_post, topic: fn post ->
"post:#{post.id}"
end
end
end
end
```
### Publishing from Mutations
```elixir
defmodule MyApp.Resolvers.Post do
def create_post(_parent, %{input: input}, _resolution) do
case MyApp.Posts.create_post(input) do
{:ok, post} ->
# Publish to subscription
Absinthe.Subscription.publish(
MyAppWeb.Endpoint,
post,
post_created: "posts"
)
{:ok, post}
{:error, changeset} ->
{:error, changeset}
end
end
end
```
### User-Specific Subscriptions
```elixir
field :user_notification, :notification do
config fn _args, %{context: %{current_user: user}} ->
{:ok, topic: "user:#{user.id}:notifications"}
end
end
# Publishing
Absinthe.Subscription.publish(
MyAppWeb.Endpoint,
notification,
user_notification: "user:#{user_id}:notifications"
)
```
## Best Practices
1. **Scope subscriptions** - Use topics to limit data exposure
2. **Authenticate connections** - Verify users in socket connect
3. **Use triggers** - Automatically publish on mutations
4. **Handle disconnections** - Clean up resources on disconnect
5. **Rate limit subscriptions** - Prevent abuse
## PubSub Configuration
```elixir
# config/config.exs
config :my_app, MyAppWeb.Endpoint,
pubsub_server: MyApp.PubSub
# application.ex
children = [
{Phoenix.PubSub, name: MyApp.PubSub},
MyAppWeb.Endpoint,
{Absinthe.Subscription, MyAppWeb.Endpoint}
]
```
## Authorization in Subscriptions
```elixir
field :private_messages, :message do
config fn _args, %{context: context} ->
case context do
%{current_user: %{id: user_id}} ->
{:ok, topic: "user:#{user_id}:messages"}
_ ->
{:error, "Unauthorized"}
end
end
end
```
## Anti-Patterns
- Don't publish sensitive data to broad topics
- Avoid subscriptions without authentication
- Don't skip connection-level authorization
- Avoid overly granular topics (performance impact)Related Skills
absinthe-schema
Use when designing GraphQL schemas with Absinthe. Covers type definitions, interfaces, unions, enums, and schema organization patterns.
absinthe-resolvers
Use when implementing GraphQL resolvers with Absinthe. Covers resolver patterns, dataloader integration, batching, and error handling.
tech-blog
Generates comprehensive technical blog posts, offering detailed explanations of system internals, architecture, and implementation, either through source code analysis or document-driven research.
modal-deployment
Run Python code in the cloud with serverless containers, GPUs, and autoscaling using Modal. This skill enables agents to generate code for deploying ML models, running batch jobs, serving APIs, and scaling compute-intensive workloads.
astro
This skill provides essential Astro framework patterns, focusing on server-side rendering (SSR), static site generation (SSG), middleware, and TypeScript best practices. It helps AI agents implement secure authentication, manage API routes, and debug rendering behaviors within Astro projects.
ux
This AI agent skill provides comprehensive guidance for creating professional and insightful User Experience (UX) designs, covering user research, information architecture, interaction design, visual guidance, and usability evaluation. It aims to produce actionable, user-centered solutions that avoid generic AI aesthetics.
vly-money
Generate crypto payment links for supported tokens and networks, manage access to X402 payment-protected content, and provide direct access to the vly.money wallet interface.
chrome-debug
This skill empowers AI agents to debug web applications and inspect browser behavior using the Chrome DevTools Protocol (CDP), offering both collaborative (headful) and automated (headless) modes.
lets-go-rss
A lightweight, full-platform RSS subscription manager that aggregates content from YouTube, Vimeo, Behance, Twitter/X, and Chinese platforms like Bilibili, Weibo, and Douyin, featuring deduplication and AI smart classification.
ontopo
An AI agent skill to search for Israeli restaurants, check table availability, view menus, and retrieve booking links via the Ontopo platform, acting as an unofficial interface to its data.
whisper-transcribe
Transcribes audio and video files to text using OpenAI's Whisper CLI, enhanced with contextual grounding from local markdown files for improved accuracy.
grail-miner
This skill assists in setting up, managing, and optimizing Grail miners on Bittensor Subnet 81, handling tasks like environment configuration, R2 storage, model checkpoint management, and performance tuning.