I wanna talk about an idea for command generator + GraphQL. (Join-Monster like)
See original GitHub issueFirst I declare this link as a reference “Logic” https://github.com/stems/join-monster
This is a specific idea for anyone trying to use Redis with GraphQL. (you really can use it, the problem is the complexity with time and I’m trying to solve with this idea below)
Gradually I will analyze how IORedis “Core” works and then see if I spend some time modifying the Join-monster so that this idea may work. Or do something else with Redis Graph - Let’s get down to business.
The idea is to use the Join-Monster concept. Join-Monster is a query planning and data fetching for SQL. With it you can generate query based on your GraphQL schema. Its reads the request and transforms the GraphQL request into a SQL. Then you can send SQL by Knex, Sequelize or any other.
The big thing is that it only sends what was requested in a single batch. Avoiding over-fetching.
Hence, what I imagined was that: take this concept from Join-monster. And try to implement it in two ways. Or by using it to generate a requested through IORedis to Redis Graph or use it to generate general Redis commands for the IORedis.
What do you think? I think such a feature would be interesting to generate clean code on resolvers. And it makes it more dynamic.
Example:
// Join monster Reads Schema
input User {
id: Int!
Name: String!
Password: String!
Phone: String!
email: String
}
//The user request this Query
mutation {
createUser(input: {
id: 999,
Name: "Michel",
Password: "12345678",
Phone: "9999999999",
email: "michel@ea.com",
})
}
//Join-Monster does this graph
let MyJoinMonsterData = 'GRAPH.CREATENODE', 'User', 'id', '999', 'Name', 'Michel', 'Password', '12345678', 'Phone', '9999999999', 'email', 'michel@ea.com'
or
let MyJoinMonsterData = 'hmset' , 'User:id999', 'Name', 'Michel', 'Password', '12345678', 'Phone', '9999999999', 'email', 'michel@ea.com'
//pack and send In Resolver:
redis.call(MyJoinMonsterData);
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top GitHub Comments
A pipeline would be enough in this case:
Thanks for the details. It’s indeed a little complex to map a graph request to a Redis structure. The most important part is, there’s not a standard on how to store relations in Redis. For instance, m-m can be implemented in Redis using set/string or zset, so it’s impossible to decide which command should be used to resolve the graph query.
Using the graph module may be a way to solve the problem. However, I noticed there’s a module/standard about implementing the relations with Redis: https://github.com/soveran/ohm. I’m not sure but it may be easier if we build the query resolver on the top of it.
A question is why
MULTI
is needed here. Transaction in Redis is a simple layer to make sure that the commands are executed sequentially. However, if any commands fail, other commands will be executed normally.