graphql-ruby-client
Advanced tools
Comparing version 1.9.3 to 1.9.4
{ | ||
"name": "graphql-ruby-client", | ||
"version": "1.9.3", | ||
"version": "1.9.4", | ||
"description": "JavaScript client for graphql-ruby", | ||
@@ -12,2 +12,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@apollo/client": "^3.3.13", | ||
"@types/actioncable": "^5.2.3", | ||
@@ -23,2 +24,3 @@ "@types/glob": "^7.1.1", | ||
"ably": "1.2.6", | ||
"graphql": "^15.0.0", | ||
"jest": "^25.0.0", | ||
@@ -25,0 +27,0 @@ "nock": "^11.0.0", |
@@ -7,2 +7,3 @@ /// <reference types="zen-observable" /> | ||
}, Record<string, any>, Record<string, any>>; | ||
declare type ConnectionParams = object | ((operation: Operation) => object); | ||
declare class ActionCableLink extends ApolloLink { | ||
@@ -12,3 +13,3 @@ cable: Cable; | ||
actionName: string; | ||
connectionParams: object; | ||
connectionParams: ConnectionParams; | ||
constructor(options: { | ||
@@ -18,3 +19,3 @@ cable: Cable; | ||
actionName?: string; | ||
connectionParams?: object; | ||
connectionParams?: ConnectionParams; | ||
}); | ||
@@ -21,0 +22,0 @@ request(operation: Operation, _next: NextLink): Observable<RequestResult>; |
@@ -35,8 +35,10 @@ "use strict"; | ||
var actionName = _this.actionName; | ||
var subscription = _this.cable.subscriptions.create(Object.assign({}, { | ||
var connectionParams = (typeof _this.connectionParams === "function") ? | ||
_this.connectionParams(operation) : _this.connectionParams; | ||
var channel = _this.cable.subscriptions.create(Object.assign({}, { | ||
channel: _this.channelName, | ||
channelId: channelId | ||
}, _this.connectionParams), { | ||
}, connectionParams), { | ||
connected: function () { | ||
this.perform(actionName, { | ||
channel.perform(actionName, { | ||
query: operation.query ? graphql_1.print(operation.query) : null, | ||
@@ -59,3 +61,3 @@ variables: operation.variables, | ||
// Make the ActionCable subscription behave like an Apollo subscription | ||
return Object.assign(subscription, { closed: false }); | ||
return Object.assign(channel, { closed: false }); | ||
}); | ||
@@ -62,0 +64,0 @@ }; |
@@ -32,3 +32,2 @@ "use strict"; | ||
connected: function () { | ||
var _this = this; | ||
// applyMiddlewares code is inspired by networkInterface internals | ||
@@ -49,4 +48,3 @@ var opts = Object.assign({}, networkInterface._opts); | ||
}); | ||
// This goes to the #execute method of the channel | ||
_this.perform("execute", channelParams); | ||
channel.perform("execute", channelParams); | ||
}); | ||
@@ -53,0 +51,0 @@ }, |
@@ -11,3 +11,3 @@ "use strict"; | ||
// Register the subscription by subscribing to the channel | ||
var subscription = cable.subscriptions.create({ | ||
var channel = cable.subscriptions.create({ | ||
channel: "GraphqlChannel", | ||
@@ -34,3 +34,4 @@ channelId: channelId, | ||
} | ||
this.perform("execute", channelParams); | ||
channel.perform('send', channelParams); | ||
channel.perform("execute", channelParams); | ||
}, | ||
@@ -57,3 +58,3 @@ // This result is sent back from ActionCable. | ||
dispose: function () { | ||
subscription.unsubscribe(); | ||
channel.unsubscribe(); | ||
} | ||
@@ -60,0 +61,0 @@ }; |
110392
2314
19