Socket
Socket
Sign inDemoInstall

graphql-subscriptions

Package Overview
Dependencies
Maintainers
4
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-subscriptions - npm Package Compare versions

Comparing version 0.4.3 to 0.4.4

4

CHANGELOG.md
# Changelog
### vNEXT
- ...
### 0.4.4
- Avoid infinite loop after the last consumer unsubscribes, [Issue #81](https://github.com/apollographql/graphql-subscriptions/issues/81) [PR #84](https://github.com/apollographql/graphql-subscriptions/pull/84)
### 0.4.3

@@ -7,0 +9,0 @@ - Properly propagate return() and throw() through withFilter [PR #74](https://github.com/apollographql/graphql-subscriptions/pull/74)

@@ -16,3 +16,5 @@ "use strict";

var FIRST_EVENT = 'FIRST_EVENT';
function buildSchema(iterator) {
var defaultFilter = function (payload) { return true; };
function buildSchema(iterator, filterFn) {
if (filterFn === void 0) { filterFn = defaultFilter; }
return new graphql_1.GraphQLSchema({

@@ -35,3 +37,3 @@ query: new graphql_1.GraphQLObjectType({

type: graphql_1.GraphQLString,
subscribe: with_filter_1.withFilter(function () { return iterator; }, function () { return true; }),
subscribe: with_filter_1.withFilter(function () { return iterator; }, filterFn),
resolve: function (root) {

@@ -47,3 +49,3 @@ return 'FIRST_EVENT';

it('should allow subscriptions', function () {
var query = graphql_1.parse("\n subscription S1 {\n testSubscription\n }\n ");
var query = graphql_1.parse("\n subscription S1 {\n\n testSubscription\n }\n ");
var pubsub = new pubsub_1.PubSub();

@@ -61,2 +63,26 @@ var origIterator = pubsub.asyncIterator(FIRST_EVENT);

});
it('should detect when the payload is done when filtering', function (done) {
var query = graphql_1.parse("\n subscription S1 {\n testSubscription\n }\n ");
var pubsub = new pubsub_1.PubSub();
var origIterator = pubsub.asyncIterator(FIRST_EVENT);
var counter = 0;
var filterFn = function () {
counter++;
if (counter > 10) {
var e = new Error('Infinite loop detected');
done(e);
throw e;
}
return false;
};
var schema = buildSchema(origIterator, filterFn);
var results = subscription_1.subscribe(schema, query);
expect(iterall_1.isAsyncIterable(results)).to.be.true;
results.next();
results.return();
pubsub.publish(FIRST_EVENT, {});
setTimeout(function (_) {
done();
}, 500);
});
it('should clear event handlers', function () {

@@ -63,0 +89,0 @@ var query = graphql_1.parse("\n subscription S1 {\n testSubscription\n }\n ");

@@ -16,3 +16,3 @@ "use strict";

var payload = _a[0], filterResult = _a[1];
if (filterResult === true) {
if (filterResult === true || payload.done === true) {
return payload;

@@ -19,0 +19,0 @@ }

{
"name": "graphql-subscriptions",
"version": "0.4.3",
"version": "0.4.4",
"description": "GraphQL subscriptions for node.js",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -15,3 +15,3 @@ [![npm version](https://badge.fury.io/js/graphql-subscriptions.svg)](https://badge.fury.io/js/graphql-subscriptions) [![GitHub license](https://img.shields.io/github/license/apollostack/graphql-subscriptions.svg)](https://github.com/apollostack/graphql-subscriptions/blob/license/LICENSE)

### Getting started with your first subscritpion
### Getting started with your first subscription

@@ -76,3 +76,3 @@ To begin with GraphQL subscriptions, start by defining a GraphQL `Subscription` type in your schema:

To do so, we can use `withFilter` helper from this package, which wraps `AsyncItrator` with a filter function, and let you control each publication for each user.
To do so, we can use `withFilter` helper from this package, which wraps `AsyncIterator` with a filter function, and let you control each publication for each user.

@@ -79,0 +79,0 @@ `withFilter` API:

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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