Comments (11)
I understand completely the reason and also I would have done it this way in order to avoid managing the clients connections on this package, but I would like to have a default client being created for you as this is two connections.
My plan would be to create optional fields to provide the publish and subscribe connection by the user, create optional dependency on redisio and if the user has not provided subscribe or publish clients then I will create a default one (check that the dependency is satisfied).
If the user has not supplied the clients and the dependency is missing, throw an error that directs the user.
I would like to have this logic in order to allow users fast prototyping as subscriptions could be a bit of a hassle to setup at the moment.
What do you think of this plan?
from graphql-redis-subscriptions.
Adding to the discussion the current node-redis roadmap redis/node-redis#1040
from graphql-redis-subscriptions.
BTW, @amitshlo Will gladly merge a PR.
from graphql-redis-subscriptions.
Like you saw, I started working on it.
After we saw the createClient function is deprecated I started to wonder how I should mock the Redis client for the tests.
After some research and a few trys to implement a mock for 'new Redis({...})' I saw (and read) that the best practice is to send a client (created by the user) in the constructor.
Any thoughts (and, what do you think about the fact that people will need 2 clients to send)?
from graphql-redis-subscriptions.
Sounds good, actually it's also done in many packages of this kind (session stores for example).
But you have to forgive me, I'm not sure I totally understand what "optional dependency" mean. The package will have to have 'ioredis' as a dependency.
from graphql-redis-subscriptions.
I mean npm's optional https://docs.npmjs.com/files/package.json#optionaldependencies
Partly unknown feature but very helpful for these kind of things.
What you do is adding ioredis as optional dep and also as dev dep and then use require in a try-catch block.
from graphql-redis-subscriptions.
OK, very cool!
from graphql-redis-subscriptions.
In my opinion both option 1 and 2 should be implemented at some point.
Being able to pass in subscriber and publisher client would mean the library consumer has direct and explicit control of the redis streams.
Regardless of whether option 1 gets implemented though I do think that ioredis
would be a better default than node_redis
at this point due to the out-of-the-box sentinel support.
from graphql-redis-subscriptions.
@amitshlo any status on the PR you are working on? I would also happily contribute to implementing one of the above options.
from graphql-redis-subscriptions.
@julienvincent it's actually almost complete, there's one comment @davidyaha gave me about tests that I don't understand, so I'm waiting for him to reply...
from graphql-redis-subscriptions.
@amitshlo I didn't see you had already submitted, looks good. I'm very keen to see it #78 get merged
from graphql-redis-subscriptions.
Related Issues (20)
- Update ioredis HOT 1
- pub/sub type safety improvements
- Ability to dynamically add/remove topics to/from asyncIterator
- Fail to startup with IOREDIS v5.0.5 HOT 1
- When filtering on subscriptions, parameters are always undefined HOT 1
- ID of the payload returned by the subscription is always null | undefined HOT 1
- Getting Type 'Redis' is not assignable to type 'RedisClient' on v2.5.0 HOT 2
- issue with Redis , no construct
- Node Redis Support HOT 2
- pubsub.asyncIterator should return an AsyncIterable
- TS2322: Type 'Redis' is not assignable to type 'RedisClient'. HOT 6
- Support sharded pub/sub
- Error: Connection is closed. with pubsub HOT 1
- Race condition with simultaneous subscribe + quick unsubscribe HOT 9
- Please update Readme.md with required redis ACL perms for cluster HOT 1
- Callback when connection is closed?
- graphql-redis-subscriptions version 2.6.0 is not working with Node 16.0.0 HOT 1
- inside docker graphql-redis-subscriptions searches to connect to localhost HOT 2
- Simple example not working with ioredis 5 due to mismatched types HOT 1
- Weird bug since 2.6.1 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-redis-subscriptions.