Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aws-appsync-subscription-link

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-appsync-subscription-link - npm Package Compare versions

Comparing version 1.0.1 to 2.0.1

__tests__/link/realtime-subscription-handshake-link-test.ts

8

CHANGELOG.md

@@ -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)

10

lib/index.d.ts

@@ -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 };

52

lib/index.js

@@ -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"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc