Skip to content

Commit 2b03278

Browse files
committed
Support overloading Channel Name
1 parent d5fd645 commit 2b03278

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

javascript_client/src/subscriptions/createActionCableFetcher.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { Consumer, Subscription } from "@rails/actioncable"
55
type ActionCableFetcherOptions = {
66
consumer: Consumer,
77
url: string,
8+
channelName = "GraphqlChannel"
89
fetch?: typeof fetch,
910
fetchOptions?: any,
1011
}
@@ -18,6 +19,7 @@ export default function createActionCableFetcher(options: ActionCableFetcherOpti
1819
let currentChannel: Subscription | null = null
1920
const consumer = options.consumer
2021
const url = options.url
22+
const channelName = options.channelName
2123

2224
const subscriptionFetcher = async function*(graphqlParams: any, fetcherOpts: any) {
2325
let isSubscription = false;
@@ -33,7 +35,7 @@ export default function createActionCableFetcher(options: ActionCableFetcherOpti
3335

3436
if (isSubscription) {
3537
currentChannel?.unsubscribe()
36-
currentChannel = consumer.subscriptions.create("GraphqlChannel",
38+
currentChannel = consumer.subscriptions.create(channelName,
3739
{
3840
connected: function() {
3941
currentChannel?.perform("execute", {

0 commit comments

Comments
 (0)