aws-appsync-subscription-link
Advanced tools
Comparing version 1.0.1 to 2.0.1
@@ -6,2 +6,10 @@ # Change Log | ||
<a name="2.0.1"></a> | ||
## [2.0.1](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@1.0.1...aws-appsync-subscription-link@2.0.1) (2019-11-15) | ||
**Note:** Version bump only for package aws-appsync-subscription-link | ||
<a name="1.0.1"></a> | ||
@@ -8,0 +16,0 @@ ## 1.0.1 (2019-10-11) |
@@ -1,4 +0,6 @@ | ||
import { CONTROL_EVENTS_KEY } from './subscription-handshake-link'; | ||
import { ApolloLink } from 'apollo-link'; | ||
export declare const createSubscriptionHandshakeLink: (url: string, resultsFetcherLink?: ApolloLink) => ApolloLink; | ||
export { CONTROL_EVENTS_KEY }; | ||
import { CONTROL_EVENTS_KEY } from "./subscription-handshake-link"; | ||
import { ApolloLink } from "apollo-link"; | ||
import { UrlInfo } from "./types"; | ||
declare function createSubscriptionHandshakeLink(args: UrlInfo, resultsFetcherLink?: ApolloLink): ApolloLink; | ||
declare function createSubscriptionHandshakeLink(url: string, resultsFetcherLink?: ApolloLink): ApolloLink; | ||
export { CONTROL_EVENTS_KEY, createSubscriptionHandshakeLink }; |
@@ -18,24 +18,38 @@ "use strict"; | ||
var non_terminating_link_1 = require("./non-terminating-link"); | ||
exports.createSubscriptionHandshakeLink = function (url, resultsFetcherLink) { | ||
if (resultsFetcherLink === void 0) { resultsFetcherLink = apollo_link_http_1.createHttpLink({ uri: url }); } | ||
var realtime_subscription_handshake_link_1 = require("./realtime-subscription-handshake-link"); | ||
function createSubscriptionHandshakeLink(infoOrUrl, theResultsFetcherLink) { | ||
var resultsFetcherLink, subscriptionLinks; | ||
if (typeof infoOrUrl === "string") { | ||
resultsFetcherLink = | ||
theResultsFetcherLink || apollo_link_http_1.createHttpLink({ uri: infoOrUrl }); | ||
subscriptionLinks = apollo_link_1.ApolloLink.from([ | ||
new non_terminating_link_1.NonTerminatingLink("controlMessages", { | ||
link: new apollo_link_1.ApolloLink(function (operation, _forward) { | ||
return new apollo_link_1.Observable(function (observer) { | ||
var _a; | ||
var _b = operation.variables, _c = subscription_handshake_link_1.CONTROL_EVENTS_KEY, controlEvents = _b[_c], variables = __rest(_b, [typeof _c === "symbol" ? _c : _c + ""]); | ||
if (typeof controlEvents !== "undefined") { | ||
operation.variables = variables; | ||
} | ||
observer.next((_a = {}, _a[subscription_handshake_link_1.CONTROL_EVENTS_KEY] = controlEvents, _a)); | ||
return function () { }; | ||
}); | ||
}) | ||
}), | ||
new non_terminating_link_1.NonTerminatingLink("subsInfo", { link: resultsFetcherLink }), | ||
new subscription_handshake_link_1.SubscriptionHandshakeLink("subsInfo") | ||
]); | ||
} | ||
else { | ||
var url = infoOrUrl.url; | ||
resultsFetcherLink = theResultsFetcherLink || apollo_link_http_1.createHttpLink({ uri: url }); | ||
subscriptionLinks = new realtime_subscription_handshake_link_1.AppSyncRealTimeSubscriptionHandshakeLink(infoOrUrl); | ||
} | ||
return apollo_link_1.ApolloLink.split(function (operation) { | ||
var query = operation.query; | ||
var _a = apollo_utilities_1.getMainDefinition(query), kind = _a.kind, graphqlOperation = _a.operation; | ||
var isSubscription = kind === 'OperationDefinition' && graphqlOperation === 'subscription'; | ||
var isSubscription = kind === "OperationDefinition" && graphqlOperation === "subscription"; | ||
return isSubscription; | ||
}, apollo_link_1.ApolloLink.from([ | ||
new non_terminating_link_1.NonTerminatingLink('controlMessages', { | ||
link: new apollo_link_1.ApolloLink(function (operation, _forward) { return new apollo_link_1.Observable(function (observer) { | ||
var _a; | ||
var _b = operation.variables, _c = subscription_handshake_link_1.CONTROL_EVENTS_KEY, controlEvents = _b[_c], variables = __rest(_b, [typeof _c === "symbol" ? _c : _c + ""]); | ||
if (typeof controlEvents !== 'undefined') { | ||
operation.variables = variables; | ||
} | ||
observer.next((_a = {}, _a[subscription_handshake_link_1.CONTROL_EVENTS_KEY] = controlEvents, _a)); | ||
return function () { }; | ||
}); }) | ||
}), | ||
new non_terminating_link_1.NonTerminatingLink('subsInfo', { link: resultsFetcherLink }), | ||
new subscription_handshake_link_1.SubscriptionHandshakeLink('subsInfo'), | ||
]), resultsFetcherLink); | ||
}; | ||
}, subscriptionLinks, resultsFetcherLink); | ||
} | ||
exports.createSubscriptionHandshakeLink = createSubscriptionHandshakeLink; |
{ | ||
"name": "aws-appsync-subscription-link", | ||
"version": "1.0.1", | ||
"version": "2.0.1", | ||
"main": "lib/index.js", | ||
@@ -26,2 +26,3 @@ "license": "Apache-2.0", | ||
"apollo-link-retry": "^2.2.5", | ||
"aws-appsync-auth-link": "^2.0.1", | ||
"debug": "2.6.9", | ||
@@ -28,0 +29,0 @@ "url": "^0.11.0" |
270168
24
6060
8
+ Addedaws-appsync-auth-link@^2.0.1
+ Added@aws-crypto/sha256-js@1.2.2(transitive)
+ Added@aws-crypto/util@1.2.2(transitive)
+ Added@aws-sdk/types@3.731.0(transitive)
+ Added@aws-sdk/util-hex-encoding@3.374.0(transitive)
+ Added@aws-sdk/util-utf8-browser@3.259.0(transitive)
+ Added@smithy/types@4.1.0(transitive)
+ Added@smithy/util-hex-encoding@1.1.0(transitive)
+ Addedapollo-link@1.2.5(transitive)
+ Addedaws-appsync-auth-link@2.0.8(transitive)
+ Addedgraphql@14.7.0(transitive)
+ Addediterall@1.3.0(transitive)
+ Addedtslib@2.8.1(transitive)