davidyaha / graphql-redis-subscriptions Goto Github PK
View Code? Open in Web Editor NEWA graphql subscriptions implementation using redis and apollo's graphql-subscriptions
License: MIT License
A graphql subscriptions implementation using redis and apollo's graphql-subscriptions
License: MIT License
Branch | Build failing π¨ |
---|---|
Dependency | @types/chai |
Current Version | 4.0.1 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As @types/chai is βonlyβ a devDependency of this project it might not break production or downstream projects, but βonlyβ your build or test tools β preventing new deploys or publishes.
I recommend you give this issue a high priority. Iβm sure you can resolve this πͺ
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot π΄
Trigger Transform relies on the Subscription Manager constructor which is now deprecated.
Is it still possible to do filtering based upon the redis subscription?
I am curious because I am getting a subscriptionsClient.subscribe is not a function
error and I do not understand the source of it.
The code below in documentation,
import { RedisPubSub } from 'graphql-redis-subscriptions';
const pubsub = new RedisPubSub({
connection: {
host: REDIS_DOMAIN_NAME,
port: PORT_NUMBER,
retry_strategy: options => {
// reconnect after
return Math.max(options.attempt * 100, 3000);
}
}
});
It means replace the pubsub instance below with the pubsub instance created from new RedisPubSub right?
const SOMETHING_CHANGED_TOPIC = 'something_changed';
export const resolvers = {
Subscription: {
somethingChanged: {
subscribe: () => pubsub.asyncIterator(SOMETHING_CHANGED_TOPIC),
},
},
}
Hi, first thank you for your work in this project!
I was trying to use it subscribing to a redis topic using a pattern and doesn't seem to be working:
mySubscription: {
subscribe: (_, args) => pubsub.asyncIterator(`project.${args.id}.*`),
resolve: (payload: any, args, context, info) => {
// I received this message from which topic? Question even using [topics] in asyncIterator
return payload;
}
}
Thanks!
Branch | Build failing π¨ |
---|---|
Dependency | @types/mocha |
Current Version | 2.2.41 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As @types/mocha is βonlyβ a devDependency of this project it might not break production or downstream projects, but βonlyβ your build or test tools β preventing new deploys or publishes.
I recommend you give this issue a high priority. Iβm sure you can resolve this πͺ
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot π΄
Thanks for taking this on. I created a simplified working Github repo with Redis-backed graphql subscriptions server here: https://github.com/mikesparr/tutorial-graphql-subscriptions-redis
One challenge I saw with a lot of the docs and articles is the broken up steps did not include the full content, so users have to search around or trial/error to get it to work and with all the (deprecated) features and mentions it is tough to follow.
Support PSUBSCRIBE
Hi @davidyaha! π
Apollo team has recently published v1.0 release of graphql-subscriptions. They've changed the return type of the method from boolean
to Promise<void>
:
https://github.com/apollographql/graphql-subscriptions/blob/master/CHANGELOG.md#100
Can you upgrade graphql-redis-subscriptions
too? Or maybe I could send the PR with this changes?
Thanks!
Hello π
I have noticed something weird I would like to discuss with you for I'm not certain of its origin and am not comfortable enough with asyncIterators to diagnose this properly.
My apologies if this doesn't come from the redis-subscriptions package.
Using this reproduction repo you can:
Doing this, you should obtain the following behavior
I am a bit confused as to why the event loop would be blocked. Is there an operation that should be async that isn't?
You can see this happen as well if the filterFn
in server/index.js:49
returns false so that nobody is interested in spinning the graphql execution for this message. (You might have to send more messages to witness it, node publisher/index.js 1000
)
Is it possible that this comes from this package, or should I rather be looking into https://github.com/apollographql/subscriptions-transport-ws ?
While I realize this makes for a lot of messages to be handled by the process
Each message triggers 300 potential executions, this makes for 150 000 graphql executions to be performed
I would expect the whole process to be slow, but not for the event loop to be totally blocked.
This is especially true when we return false
in the filterFn
function (which means the issue doesn't come from the graphql layer)
In this article it mentions delivery guarantees:
We worked with David Yahalomi to create the graphql-redis-subscriptions and graphql-mqtt-subscriptions packages, which can be easily dropped in as a replacement for the default PubSub object without making any changes to the rest of your code.
Using an external pub/sub system gives you more publication featuresβββsuch as persistence, caching, delivery guarantees and other optimizations.
Does graphql-redis-subscriptions
support guaranteed delivery, and how would one go about implementing it?
The current README.md uses the following code on the Creating the Redis Client section:
import { RedisPubSub } from 'graphql-redis-subscriptions';
import * as Redis from 'ioredis';
const options = {
host: REDIS_DOMAIN_NAME,
port: PORT_NUMBER,
retry_strategy: options => {
// reconnect after
return Math.max(options.attempt * 100, 3000);
}
};
const pubsub = new RedisPubSub({
...,
publisher: new Redis(options),
subscriber: new Redis(options)
});
It uses ioredis
as the Redis client and specifies a retry_strategy
option when creating the instance with an option
object as argument with an attempt
key. However, the ioredis
actually expects a retryStrategy
(camel-cased) with a times
numeric argument inside with the current attempt, as described on the Auto-reconnect section of their documentation.
var redis = new Redis({
// This is the default value of `retryStrategy`
retryStrategy: function(times) {
var delay = Math.min(times * 50, 2000);
return delay;
}
})
I think the current example from grapqhl-redis-subscriptions
is probably using the retry_strategy
signature from node-redis by mistake.
I started using Redis Keyspace Notifications today, and in one of my GraphQL publications, I need to watch for a Redis key expired
notification, and if so, yield something in addition to the normal JSON messages I'm publishing.
I had to write some really confusing code to merge the stream of JSON events with the stream of expired events coming from direct redis client usage.
I wish I pass a top-level parseMessage
function to RedisPubSub
like:
parseMessage: (topic: string, message: string) => {
if (topic.startsWith('__key')) return message
return JSON.parse(message)
},
If only I could do this, then my code for handling the GraphQL subscription would be really simple:
const mainTopic = `Device/${deviceId}/status`
const keyspaceTopic = `__keyspace@0__:${mainTopic}`
for await (const event of pubsub.asyncIterator([mainTopic, keyspaceTopic])) {
if (event === 'expired') yield {DeviceConnectionState: {status: 'NOT_CONNECTED'}}
else yield event
}
What do you think?
So my express server calls MY subscriptionServer function
//subscriptions.js
const { execute, subscribe } = require('graphql');
const { SubscriptionServer } = require('subscriptions-transport-ws');
const { RedisPubSub } = require('graphql-redis-subscriptions');
const schema = require('./src/schema');
const redisOptions = {
host: 'localhost',
port: 6379,
connect_timeout: 15000,
enable_offline_queue: true,
retry_unfulfilled_commands: true,
};
const pubsub = new RedisPubSub({
connection: redisOptions,
connectionListener: (err) => {
if (err) {
console.error(err); // eslint-disable-line no-console
}
console.info('Succefuly connected to redis'); // eslint-disable-line no-console
}
});
function subscriptionServer(server) {
new SubscriptionServer({
execute,
subscribe,
schema
}, {
server,
path: '/subscriptions',
});
}
module.exports = {
pubsub,
subscriptionServer
};
heres a simple subscription query
const RoomType = require('../type');
const { GraphQLNonNull, GraphQLString } = require('graphql');
const { pubsub } = require('../../../subscriptions.js');
module.exports = {
type: RoomType,
name: 'roomSubscription',
args: {
placeId: {
description: 'ID of the place',
type: new GraphQLNonNull(GraphQLString)
}
},
subscribe: () => pubsub.asyncIterator('checkedin')
};
so anytime i run this query in graphiQL i get this error
[{"message":"Schema must be an instance of GraphQLSchema. Also ensure that there are not multiple versions of GraphQL installed in your node_modules directory."}]
if i replace the pubsub with the one from graphql-subscriptions, the subscriptions work fine.
edit: publish seems to work fine, i can see logs on redis
Lots of PR ongoing and not much activity :(
Do you have any working example??? I'm completely new to this and it's hard to guess where to put all the snippets.
The readme still talks about the deprecated subscriptionManager
etc.
I tried testing the async iterator test case independently and it fails. Try to run this test.
https://github.com/veeramarni/graphql-redis-subscriptions/blob/master/src/test/integration-tests.ts
On the graphql-subscriptions github page i found
SubscriptionManager @deprecated
SubscriptionManager is the previous alternative for using graphql-js subscriptions directly, and it's now deprecated.
Could someone please provide a example without the SubscriptionManager.
Thanks in advance!
14.4.2
to 14.5.0
.π¨ View failing branch.
This version is covered by your current version range and after updating it in your project the build failed.
graphql is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
getPossibleTypes
& isPossibleType
(@IvanGoncharov)There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
Hi,
this is not an issue directly related to your repository, but as contributor of the project: https://github.com/axelspringer/graphql-google-pubsub I can say we use a very similar version of the AsyncIterator like you have. I wonder if you ran into similar issues?
We observe huge problems with memory leaks on production, where about 100 users are on the system in parallel. It takes about one hour until the memory reaches its limit and a restart of the container is triggered. We only saw this, because of our monitoring, otherwise nobody would have taken notice about it.
Heapdumps gave us the assumption, async iterator is the bad guy here:
Here my Questions:
By the way, I wonder, why you are not interested in this pull-request, which seems to adress the problem, described: #114
--> We will try that out tomorrow and come back with results.
Seems like ES6 destruction params not working after changing compilerOptions for target
to es6
. Wondering whether anyone has same issue?
resolve: function (root, { filterBoolean }) {
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
14.0.2
to 14.1.0
.π¨ View failing branch.
This version is covered by your current version range and after updating it in your project the build failed.
graphql is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
New:
Fixes:
The new version differs by 109 commits.
da61380
14.1.0
4de99f7
Merge branch 'OneCyrus-feat_listTypeForError'
0a731a5
Prettier and fix tests
a6676dc
Merge branch 'feat_listTypeForError' of https://github.com/OneCyrus/graphql-js into OneCyrus-feat_listTypeForError
37c022d
buildClientSchema: add missing tests for introspection validations (#1666)
3fef0d4
Enable Flow on buildClientSchema tests (#1665)
6876587
Move $DisableFlowOnNegativeTest to more precise locations (#1664)
b747bb4
changed type error message
8d7a5fd
Merge schema validation tests with other schema tests (#1663)
6741ac2
Add tests for GraphQLDirective (#1662)
d48e481
Move isInputType & isOutputType test to rest of predicates test (#1661)
4cdc8e2
Update Flow to 0.90.0 (#1660)
9f85d51
Remove excessive invariants (#1658)
0818c18
ignore .nyc_output dir (#1657)
9e40465
Move polyfills into separate dir and exclude them from coverage (#1656)
There are 109 commits in total.
See the full diff
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
Hello!
I'm building a real time application with graphql subscriptions and I am facing performance issues at the moment.
What I do is I use the graphql subscriptions more like a contract than for it's resolvers per say.
The data I want to pass through to the connected clients is precomputed and I know my audience from the start, therefore I don't need to run the graphql execution for as many sockets as I have connected.
Once per payload is enough, and I could just use the result of that execution to all the users (the resolvers don't do anything related to the user so it doesn't matter really).
I have been trying to implement this but I think I'm missing something and don't understand exactly how/where I could do it.
Would you mind giving me some pointers so I can implement it?
I think this is really critical for subscriptions performances, and could spend some time on it given some help.
Hi all, great work. Somewhat newbie disclosure, Im new to graphql and new to redis subscriptions but have fair amount of experience with redis in general. I'm trying to determine/conceptualize how and if I can utilize graphql-redis-subscriptions to
A. perform geo-add
B. change(re"set") the value of hash
C. perform a georadius query
Currently doing above this via a simple service but would like to experiment the same implementation via graphql-redis-subscriptions, is it feasible? Would graphql add complexity or any lag to response if feasible?
thanks! Great work!
The example code used in section Creating the Redis Client of the readme has the following import:
import * as Redis from 'ioredis';
This results in an error message:
publisher: new Redis(options),
^
TypeError: Redis is not a constructor
To fix this, you simply need to change the import to:
import Redis from 'ioredis';
Kindly update code of graphql-redis-subscriptions branch
Branch | Build failing π¨ |
---|---|
Dependency | mocha |
Current Version | 3.3.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As mocha is βonlyβ a devDependency of this project it might not break production or downstream projects, but βonlyβ your build or test tools β preventing new deploys or publishes.
I recommend you give this issue a high priority. Iβm sure you can resolve this πͺ
Mocha is now moving to a quicker release schedule: when non-breaking changes are merged, a release should happen that week.
This week's highlights:
allowUncaught
added to commandline as --allow-uncaught
(and bugfixed)--no-warnings
and --trace-warnings
flags (@sonicdoe)The new version differs by 9 commits0.
7554b31
Add Changelog for v3.4.0
9f7f7ed
Add --trace-warnings
flag
92561c8
Add --no-warnings
flag
ceee976
lint test/integration/fixtures/simple-reporter.js
dcfc094
Revert "use semistandard
directly"
93392dd
no special case for macOS running Karma locally
4d1d91d
--allow-uncaught cli option
fb1e083
fix allowUncaught in browser
4ed3fc5
Add license report and scan status
false
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot π΄
I'm working on a react application which depends highly on real time data.
Using redis pubsub and it works fine.
My problem is I have multiple deployments of this application
1 - abc.somedomain.com
2 - xyz.somedomain.com
I want to share 1 redis cluster between these 2 deployments. Now the issue is, if some data is published on some channel "channelABC" from 1st deployment, it visible for 2nd deployment as well.
Is there any way to use some kind of prefix or scope just like
https://github.com/louischatriot/node-redis-pubsub
The readme instructions has two sets of conflicting code, and both say to use them in production. Which one do I use:
Option 1:
import { RedisPubSub } from 'graphql-redis-subscriptions';
import * as Redis from 'ioredis';
const options = {
host: REDIS_DOMAIN_NAME,
port: PORT_NUMBER,
retry_strategy: options => {
// reconnect after
return Math.max(options.attempt * 100, 3000);
}
};
const pubsub = new RedisPubSub({
...,
publisher: new Redis(options),
subscriber: new Redis(options)
});
Option 2:
import { RedisPubSub } from 'graphql-redis-subscriptions';
const pubsub = new RedisPubSub({
connection: {
host: REDIS_DOMAIN_NAME,
port: PORT_NUMBER,
retry_strategy: options => {
// reconnect after
return Math.max(options.attempt * 100, 3000);
}
}
});
Not sure how to set the connection parameters
Branch | Build failing π¨ |
---|---|
Dependency | redis |
Current Version | 2.7.1 |
Type | dependency |
This version is covered by your current version range and after updating it in your project the build failed.
redis is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you itβs very likely also breaking them.
I recommend you give this issue a very high priority. Iβm sure you can resolve this πͺ
The new version differs by 35 commits.
1380ad6
fix: test on old node versions
6694c91
v.2.8.0
ad8355a
fix: add command tests
79558c5
doc: improve README readability by limiting chars to 80
51fdbb7
chore: improve new add_command and add documentation
0437aa4
enabled adding abritary commands
4f7f1ad
fix: silence auth errors on reconnect
42e8bd6
chore: stop testing Node.js 7
937081b
fix: dependency
e5c8f81
fix: revert some dev dependency updates to run tests
7e9dda1
chore: test node 8
16632f4
fix emitting internal auth error on reconnect
50774ae
fix: accept UPPER_CASE commands in send_command
789471b
chore: update peer dependency version
6934270
fix: always copy subscribe unsubscribe arguments
There are 35 commits in total.
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot π΄
Hello, i'm still halfway implementing my subscription one thing i noticed is that there was no example ( that i could find ) for peeps using an already existing Redis connection.
For instance in my case before creating the RedisPubSub i already have a connection to redis happening on my application:
client = redis.createClient({
url: url,
db : db
})
So i'm wondering if using this object as "connection" parameter for the PubSub will be enough for it to "reuse" my existing connection, as in:
var pubsub = new RedisPubSub({
connection : client,
triggerTransform: transform
})
Is that supposed to work, if not how would i go about this ?
Branch | Build failing π¨ |
---|---|
Dependency | tslint |
Current Version | 5.5.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As tslint is βonlyβ a devDependency of this project it might not break production or downstream projects, but βonlyβ your build or test tools β preventing new deploys or publishes.
I recommend you give this issue a high priority. Iβm sure you can resolve this πͺ
no-duplicate-imports
(#3075)no-submodule-imports
(#3091)space-within-parens
(#2959)member-access
(#2969)no-null-keyword
: fix x == null
to x == undefined
(#2802)no-shadowed-variable
let's you optionally ignore certain kinds of declarations (#3030)prefer-conditional-expression
adds check-else-if
(#2963)array-type
: consider this
to be simple type (#2982)await-promise
accepts not only union types but also intersection types with Promise-like types (#2987)callable-types
: don't remove export modifier of interfaces (#2962)completed-docs
: Only checks variables at the file-level. (#2950)completed-docs
: Uses correct visibility of variables. (#2950)no-floating-promises
: recognize rejection handler passed as second argument to promise.then()
(#3048)no-shadowed-variable
don't warn for shadowed type parameter on static class members (#3030)no-shadowed-variable
fixed false positive with key name in index signature (#3030)no-shadowed-variable
fixed false positive with parameter inside function decorator (#3030)no-unsafe-any
: allow truthyness and falsyness checks (#3008)no-unused-variable
fixed crash when using destructuring (#3058)one-line
correctly handles multiline type parameters (#3004)prefer-for-of
fixed false positives when array is modified, e.g. arr[i]++
(#3044)prefer-object-spread
adds parens when fixing arrow function return (#3026)prefer-object-spread
permit functions as first argument to Object.assign (#3098)space-before-function-paren
Handle default exports of functions without names like anonymous functions (fixes #3040) (#3053)./test/parse
could not be located due after consumers had run yarn clean
(#3072)no-null-keyword
allows strict comparison (#2802)no-switch-case-fall-through
matches // falls through
comments case insensitive and allows trailing text (#2983)ordered-imports
: support importEqualsDeclaration (#3102)no-inferrable-types
(#2885)prefer-conditional-expression
: ignore if-else-if
by default. Use the new "check-else-if"
option to check nested if statements (#2963)Thanks to our contributors!
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot π΄
Branch | Build failing π¨ |
---|---|
Dependency | typescript |
Current Version | 2.4.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As typescript is βonlyβ a devDependency of this project it might not break production or downstream projects, but βonlyβ your build or test tools β preventing new deploys or publishes.
I recommend you give this issue a high priority. Iβm sure you can resolve this πͺ
The new version differs by 141 commits.
8b2fe13
Update LKG.
14d95ed
Test:Block-scoped definition of Promise works
a8846bf
Skip block scope check with no error location
44f2336
Merge pull request #16633 from Microsoft/release-2.4_fixIncrementalParsing
4875a27
Add tests
15ef20d
Set the structureReused to be safemoudles when dynamic import change
6d33083
Add tests
11b9f6e
Wip-fix incremental parsing
2721fd4
In TypeScript code, never bind JSDoc normally, just set parent pointers (#16555) (#16561)
0968ed9
Revert string enum changes (#16569)
096f8cc
Update LKG
9241175
Allow running in strict mode (#16557)
f49b007
Update LKG
f1b0f59
Update version to 2.4.1
ed9cde9
Update LKG
There are 141 commits in total.
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot π΄
The subscriptions stack in Redis every time we deploy our server, meaning by now every message is sent five times to every user that's subscribed.
Any ideas why that's happening? What are we doing wrong?
Hello,
Since we implemented subscriptions in our app (including this package) we see sometimes elevated memory usage over time. I'm not quite sure what's happening in there but I see a lot of the RedisPubSub's subscriptionMap retaining some memory:
This may be due to many different things: first of all, we have a kue job queue hooked in the same pubsub. That would explain a good chunk of the retained memory ("Matrix" part in the retained objects).
However, from what I gather in your source, there is no cleaning in the subscriptionMap of the Array mapped by your subscriptionId: https://github.com/davidyaha/graphql-redis-subscriptions/blob/master/src/redis-pubsub.ts#L63:L83
I'll try to things to mitigate the issue:
Maybe we should consider mapping the subscriptions using a WeakMap, avoiding maintaining the cleaning of the retained objects in the subscription map...
according to redis/node-redis#713
redis connection die would causing node crash if none error handle attached.
while I am using the code below to fix this, but shouldn't this belongs to lib itself ?
const pubsub = new RedisPubSub({
connectionListener: (e) => null,
});
Could someone provide some code using graphql-redis-subscriptions
?
I am facing some difficulties getting the data sent to the client although the subscription is called on the server.
Add support for Redis Sentinel and Cluster.
In production most places use Sentinel or Cluster for high availability and automatic failovers.
The library now used by 'graphql-redis-subscriptions' isn't suppotring it.
Suggested solutions:
I personally think the second one is better, because it's not a breaking change and there's not much use in letting the developers send a redis instance.
Maybe I will do 2 and open a PR in the near future.
After spending about 4 hours debugging a weird error where I was getting the message Cannot convert undefined or null to object
as a message back from the WS subscribe query, I discovered that it was caused by the transpiled version of the triggerTransform example in the README:
function triggerTransform(trigger, _ref) {
var path = _ref.path;
return [trigger].concat(_toConsumableArray(path)).join('.');
}
After doing a bit of manual debugging, I discovered that the error was being thrown along this path:
The triggerTransform function is, of course, the transpiled function pasted above which is the triggerTransform
example in the README. It looks like the problem is that _ref.path
is actually undefined. The trigger
parameter is equal to a string (the channel name), and _ref
(which is the value from {path}
as the second param in the example) is undefined because the options object in the function header is an empty object for whatever reason (presumably a default option from here).
I was able to pinpoint the source by wrapping the transpiled code of both of the functions listed above in try/catch blocks and tracing out the errors.
Wondering if this is an error with the docs or a regression somewhere else, like in the coupling between this library and graphql-subscriptions?
I'm using the Date type as in this documentation page https://www.apollographql.com/docs/graphql-tools/scalars.html
Date: new GraphQLScalarType({
name: 'Date',
description: 'Date custom scalar type',
parseValue(value) {
return new Date(value); // value from the client
},
serialize(value) {
return value.getTime(); // value sent to the client
},
parseLiteral(ast) {
if (ast.kind === Kind.INT) {
return parseInt(ast.value, 10); // ast value is always in string format
}
return null;
},
}),
I'm doing a findOne with Mongoose, and pass the returned document to the pubsub like this:
pubsub.publish('bookUpdated', { bookUpdated: book });
In my network tab, in the websocket, I'm getting the following error:
value.getTime is not a function in ["bookUpdated", "events", 1, "timestamp"]
The same code works without problem with the in-memory PubSub. This bug only affects RedisPubSub. Certainly because of the use of JSON.stringify and JSON.parse. See https://stackoverflow.com/questions/4511705/how-to-parse-json-to-receive-a-date-object-in-javascript
So I'm not sure if this can be considered a graphql-redis-subscriptions bug, but both PubSub are supposed to give the same result, I think.
Hello! First of all thanks for your time and your work on making and maintaining this lib! π
We're trying to migrate from the basic 'graphql-subscriptions'
package to this one.
We have a use case in which we don't just publish a single change, e.g. a plain object { ... }
, but a bunch of them; so we publish a Set([ ... ])
of changes in one shot. The problem is that the code is doing this:
public async publish<T>(trigger: string, payload: T): Promise<void> {
await this.redisPublisher.publish(trigger, JSON.stringify(payload));
}
Here the Set
is lost because of the assumption that everything would be a String. π
However, ioredis
supports publishing Buffers as well:
redis.on("messageBuffer", function(channel, message) {
// Both `channel` and `message` are buffers.
});
Would you be open to add this feature?
Many thanks! π
Branch | Build failing π¨ |
---|---|
Dependency | ioredis |
Current Version | 3.2.1 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
ioredis is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 4 commits.
e16cf7e
chore(release): 3.2.2
b8ba3e5
docs(CHANGELOG): 3.2.2
3037b6e
deps: update debug to v2.6.9 (#543)
cb25999
chore: add stale config
See the full diff
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
I'm getting the following error when attempting to install graphql-redis-subscriptions
warning "graphql-redis-subscriptions > [email protected]" has incorrect peer dependency "graphql@^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.1"
The latest version of graphql
as of submitting this issue is 0.11.7
. My cursory test seems to show that it works with the new version of graphql, not sure of the work involved in just getting that updated.
Hi,
I'm trying to use your module in bundle with an MQTT broker which also relies on Redis, as described in StackOverflow.
I point out that if I try to use import * as Redis from 'ioredis';
as described here, I get TypeError: Redis is not a constructor
.
When I try to publish something, I can see commands forwarded to redis through redis-cli monitor
command, but I get that error inside mqemitter package which make crash the server.
I know that mqemitter it's not part of your module, the fact is I'm not properly sure where is the problem, since when I use the default PubSub
implementation of graphql-subscription
module I don't get this type of errors.
Let me know if you can spot something particular,
best regards
Hi,
Is it possible to add a redis password when establishing a connection?
Thanks,
Hi there. I'm looking at subscriptions in Node coming from some experience with graphQL in Elixir. They offer an option in Absinthe where instead of manually publishing arbitrarily named events, you can subscribe to mutations themselves:
kinda like:
Subscription: {
userUpdated: {
subscribe: () => pubsub.triggeredBy(['updateUserName', 'updateUserAddress'])
},
We would need to publish all mutations with something like a pubsub middleware that would publish the mutation and the payload. That way we wouldn't need to create subscription payloads as the payload would be the mutation payload, in this case the User payload. This is almost always desirable anyway: having the mutation payload be the subscription payload.
It's a bit confusing that we are using the RedisClient constructor directly, as all of the docs (including options) for node_redis are around redis.createClient
. Because of this, there is at least one discrepancy with passing connection options to redis. According to current node_redis docs here, the client should be able to specify a url
option rather than passing host
and port
options through the connection hash that you pass through to node_redis
. However, the RedisClient
constructor does not support a url
property. The url
property is normalized and split into host
and port
properties through a call here, which dives into lib/createClient.js
and parsed into host
and port
here. Passing the url
option through options.connection
in RedisPubSub
constructor causes an attempted connection to redis://127.0.0.1:6379
, regardless of what is passed via url
. Because of this discrepancy, and for the sake of developer sanity, I think it makes more sense to interact with the publicly documented API of node_redis
(aka, redis.createClient(options: Object)
rather than interface with the RedisClient
constructor directly as it fits more inline with the node_redis
docs and this lib provides a passthrough via options.connection
which will be assumed to follow the node_redis
publicly doc'd API. I am willing to put in a PR to make this switch later this week.
Hi,
graphql-subscriptions has been released with version 0.4.0
, and graphql-redis-subscriptions does not work, because breaking changes.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.