11import { ApolloLink , Observable , FetchResult , Operation , NextLink } from "@apollo/client/core"
2- import { Cable , Channel } from "actioncable"
2+ import { Cable } from "actioncable"
33import { print } from "graphql"
44
55type RequestResult = FetchResult < { [ key : string ] : any ; } , Record < string , any > , Record < string , any > >
@@ -25,13 +25,12 @@ class ActionCableLink extends ApolloLink {
2525 return new Observable ( ( observer ) => {
2626 var channelId = Math . round ( Date . now ( ) + Math . random ( ) * 100000 ) . toString ( 16 )
2727 var actionName = this . actionName
28- var subscription = this . cable . subscriptions . create ( Object . assign ( { } , {
28+ var channel = this . cable . subscriptions . create ( Object . assign ( { } , {
2929 channel : this . channelName ,
3030 channelId : channelId
3131 } , this . connectionParams ) , {
3232 connected : function ( ) {
33- // Broken since https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52421 ??
34- ( ( this as unknown ) as Channel ) . perform (
33+ channel . perform (
3534 actionName ,
3635 {
3736 query : operation . query ? print ( operation . query ) : null ,
@@ -52,9 +51,8 @@ class ActionCableLink extends ApolloLink {
5251 }
5352 }
5453 } )
55-
5654 // Make the ActionCable subscription behave like an Apollo subscription
57- return Object . assign ( subscription , { closed : false } )
55+ return Object . assign ( channel , { closed : false } )
5856 } )
5957 }
6058}
0 commit comments