Update to use PubSub in development

- for some reason RedisPubSub works locally, but with docker it tries to
  connect to Redis and therefore it doesn't pass the build. PubSub is
imported from graphql-subscriptions which is a dependency of
apollo-server-express, and suitable for dev purposes.
This commit is contained in:
mattwr18 2020-02-10 17:19:19 +01:00
parent 069c637c84
commit 409150813d

View File

@ -2,7 +2,6 @@ import express from 'express'
import http from 'http'
import helmet from 'helmet'
import { ApolloServer } from 'apollo-server-express'
import CONFIG from './config'
import middleware from './middleware'
import { getNeode, getDriver } from './db/neo4j'
@ -10,6 +9,7 @@ import decode from './jwt/decode'
import schema from './schema'
import webfinger from './activitypub/routes/webfinger'
import { RedisPubSub } from 'graphql-redis-subscriptions'
import { PubSub } from 'graphql-subscriptions'
import Redis from 'ioredis'
export const NOTIFICATION_ADDED = 'NOTIFICATION_ADDED'
@ -23,14 +23,13 @@ const options = {
return Math.min(times * 50, 2000)
},
}
if (options.host && options.port && options.password) {
prodPubsub = new RedisPubSub({
publisher: new Redis(options),
subscriber: new Redis(options),
})
} else {
devPubsub = new RedisPubSub()
devPubsub = new PubSub()
}
export const pubsub = prodPubsub || devPubsub
const driver = getDriver()