Skip to content

Commit cf0a3fe

Browse files
committed
Hack around .perform typecheck errors
1 parent 03c2bb6 commit cf0a3fe

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

javascript_client/src/subscriptions/ActionCableLink.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ApolloLink, Observable, FetchResult, Operation, NextLink } from "@apollo/client/core"
2-
import { Cable } from "actioncable"
2+
import { Cable, Channel } from "actioncable"
33
import { print } from "graphql"
44

55
type RequestResult = FetchResult<{ [key: string]: any; }, Record<string, any>, Record<string, any>>
@@ -30,7 +30,8 @@ class ActionCableLink extends ApolloLink {
3030
channelId: channelId
3131
}, this.connectionParams), {
3232
connected: function() {
33-
this.perform(
33+
// Broken since https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52421 ??
34+
((this as unknown) as Channel).perform(
3435
actionName,
3536
{
3637
query: operation.query ? print(operation.query) : null,

javascript_client/src/subscriptions/ActionCableSubscriber.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import printer from "graphql/language/printer"
22
import registry from "./registry"
3-
import { Cable } from "actioncable"
3+
import { Cable, Channel } from "actioncable"
44

55
interface ApolloNetworkInterface {
66
applyMiddlewares: Function
@@ -52,9 +52,10 @@ class ActionCableSubscriber {
5252
variables: variables,
5353
operationId: operationId,
5454
operationName: operationName,
55-
})
55+
}) as any
5656
// This goes to the #execute method of the channel
57-
_this.perform("execute", channelParams)
57+
// Broken since https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52421
58+
((_this as unknown) as Channel).perform("execute", channelParams)
5859
})
5960
},
6061
// Payload from ActionCable should have at least two keys:

javascript_client/src/subscriptions/createActionCableHandler.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Cable } from "actioncable"
1+
import { Cable, Channel } from "actioncable"
22

33
/**
44
* Create a Relay Modern-compatible subscription handler.
@@ -41,8 +41,10 @@ function createActionCableHandler(options: ActionCableHandlerOptions) {
4141
query: operation.text
4242
}
4343
}
44+
// `this.perform` stopped working after https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52421
45+
((this as unknown) as Channel).perform('send', channelParams);
4446

45-
this.perform("execute", channelParams)
47+
((this as unknown) as Channel).perform("execute", channelParams)
4648
},
4749
// This result is sent back from ActionCable.
4850
received: function(payload: { result: { errors: any[], data: object }, more: boolean}) {

0 commit comments

Comments
 (0)