Skip to content

Commit

Permalink
Merge pull request #7 from fubhy/fix-stop
Browse files Browse the repository at this point in the history
Unsubscribe active subscriptions on 'stop' signal.
  • Loading branch information
PCreations committed Jun 5, 2018
2 parents 11d6764 + ac7c810 commit c930379
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/MessageTypes.js
@@ -1,4 +1,5 @@
export const GQL_START = 'start';
export const GQL_STOP = 'stop';
export const GQL_DATA = 'data';
export const GQL_ERROR = 'error';
export const GQL_COMPLETE = 'complete';
export const GQL_COMPLETE = 'complete';
9 changes: 5 additions & 4 deletions src/workerUtils.js
Expand Up @@ -107,11 +107,12 @@ const getOnMessage = ({ schema, context }) => {
const opId = message.id;
if (typeof opId !== 'undefined') {
switch (message.type) {
case MessageTypes.GQL_STOP:
unsubscribe(opId);
break;

case MessageTypes.GQL_START:
// if we already have a subscription with this id, unsubscribe from it first
if (connectionContext.operations && connectionContext.operations[opId]) {
unsubscribe(opId);
}
unsubscribe(opId);

const baseParams = {
query: message.payload.query,
Expand Down

0 comments on commit c930379

Please sign in to comment.