How to use the graphql-subscriptions.SubscriptionManager function in graphql-subscriptions

To help you get started, we’ve selected a few graphql-subscriptions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github withspectrum / spectrum / server / subscriptions / manager.js View on Github external
//@flow

/**
 * Create the subscription manager to be used by the subscription server
 */
const { SubscriptionManager } = require('graphql-subscriptions');
const schema = require('../schema');
const pubsub = require('./listeners/pubsub');
const channels = require('./listeners/channels');

module.exports = new SubscriptionManager({
  schema,
  pubsub,
  // setupFunctions map a Subscription type as defined in the
  // schema (e.g. messageAdded) to certain channels (e.g. MESSAGE_ADDED)
  // Subscriptions can also listen to multiple channels
  setupFunctions: {
    messageAdded: (_, { thread }) => ({
      [channels.MESSAGE_ADDED]: {
        filter: message => message.threadId === thread,
      },
    }),
    notificationAdded: (_, __, { user }) => ({
      [channels.NOTIFICATION_ADDED]: {
        filter: notification => notification,
      },
    }),
github tmeasday / create-graphql-server / test / output-app / server / subscriptions.js View on Github external
import { PubSub, SubscriptionManager } from 'graphql-subscriptions';
import schema from '../schema';

const pubsub = new PubSub();
const subscriptionManager = new SubscriptionManager({
  schema,
  pubsub,
  setupFunctions: {
  },
});

export { subscriptionManager, pubsub };
github erxes / erxes-widgets-api / src / data / subscriptionManager.js View on Github external
import { PubSub, SubscriptionManager } from 'graphql-subscriptions';
import schema from '.';

export const pubsub = new PubSub();

export const subscriptionManager = new SubscriptionManager({
  schema,
  pubsub,
  setupFunctions: {
    messageInserted: (options, args) => ({
      newMessagesChannel: {
        filter: message => message.conversationId === args.conversationId,
      },
    }),
  },
});
github Akryum / apollo-server-example / subscriptions.js View on Github external
import { PubSub, SubscriptionManager } from 'graphql-subscriptions';
import schema from './schema';

const pubsub = new PubSub();
const subscriptionManager = new SubscriptionManager({
  schema,
  pubsub,
  setupFunctions: {
    tagAdded: (options, args) => ({
      tagAdded: {
        filter: tag => tag.type === args.type,
      },
    }),
  },
});

export { subscriptionManager, pubsub };
github cdmbase / fullstack-pro / packages / sample-server / src / subscriptions.ts View on Github external
import { PubSub, SubscriptionManager } from "graphql-subscriptions";
import { schema } from "./schema";
import { Observable } from 'rxjs';

const pubsub = new PubSub();
const subscriptionManager = new SubscriptionManager({
    schema,
    pubsub,
    setupFunctions: {

    },
});

export { subscriptionManager, pubsub };

Observable.interval(1000)
.map(() => new Date())
.subscribe((clock: Date) => {
    pubsub.publish("clock", clock);
})
github davidgljay / nametag / server / src / graph / subscriptions / SubscriptionManager.js View on Github external
const { SubscriptionManager } = require('graphql-subscriptions')
const schema = require('../schema')
const pubsub = require('./pubsub')

module.exports = new SubscriptionManager({
  schema,
  pubsub,
  setupFunctions: {
    messageAdded: (options, args) => ({
      messageAdded: {
        filter: message => message.room === args.roomId &&
                            (
                              !message.recipient ||
                              message.recipient === args.nametagId ||
                              message.author === args.nametagId
                            )
      }
    }),
    messageDeleted: (options, args) => ({
      messageDeleted: {
        filter: message => message.room === args.roomId
github erxes / erxes-widgets / data / subscription-manager.js View on Github external
import { PubSub, SubscriptionManager } from 'graphql-subscriptions';
import schema from './schema';

const pubsub = new PubSub();

const subscriptionManager = new SubscriptionManager({
  schema,
  pubsub,
  setupFunctions: {
    messageInserted: (options, args) => ({
      newMessagesChannel: {
        filter: (message) =>
          message.conversationId === args.conversationId
        ,
      },
    }),
  },
});

export { subscriptionManager, pubsub };
github tmeasday / create-graphql-server / skel / server / subscriptions.js View on Github external
import { PubSub, SubscriptionManager } from 'graphql-subscriptions';
import schema from '../schema';

const pubsub = new PubSub();
const subscriptionManager = new SubscriptionManager({
  schema,
  pubsub,
  setupFunctions: {
  },
});

export { subscriptionManager, pubsub };
github GraphqlBA / codenames-gql / server / index.js View on Github external
import { SubscriptionServer } from 'subscriptions-transport-ws'
import typeDefs from '@src/schema'
import resolvers from '@src/resolvers'
import { Model } from 'objection'
import knexConfig from './knexfile'
import Knex from 'knex'

const knex = Knex(knexConfig.development)
Model.knex(knex)

const schema = makeExecutableSchema({
  typeDefs,
  resolvers
})

const subscriptionManager = new SubscriptionManager({
  schema,
  pubsub,
  setupFunctions: {
    cardSelected: (options, args) => ({
      cardSelected: {
        filter: card => card.game_id === Number(args.gameId)
      }
    })
  }
})

const PORT = process.env.PORT || 3000
const WS_PORT = process.env.WS_PORT || 5000

var app = express()
github CommonGarden / Grow-IoT / src / subscriptions.js View on Github external
import { PubSub, SubscriptionManager } from 'graphql-subscriptions';
import schema from 'grow-graphql-schema/schema';

const pubsub = new PubSub();
const subscriptionManager = new SubscriptionManager({
  schema,
  pubsub,
});

export { subscriptionManager, pubsub };

graphql-subscriptions

GraphQL subscriptions for node.js

MIT
Latest version published 2 years ago

Package Health Score

79 / 100
Full package analysis