Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//@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,
},
}),
import { PubSub, SubscriptionManager } from 'graphql-subscriptions';
import schema from '../schema';
const pubsub = new PubSub();
const subscriptionManager = new SubscriptionManager({
schema,
pubsub,
setupFunctions: {
},
});
export { subscriptionManager, pubsub };
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,
},
}),
},
});
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 };
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);
})
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
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 };
import { PubSub, SubscriptionManager } from 'graphql-subscriptions';
import schema from '../schema';
const pubsub = new PubSub();
const subscriptionManager = new SubscriptionManager({
schema,
pubsub,
setupFunctions: {
},
});
export { subscriptionManager, pubsub };
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()
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 };