question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I wanna talk about an idea for command generator + GraphQL. (Join-Monster like)

See original GitHub issue

First 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
luincommented, Sep 18, 2017

A pipeline would be enough in this case:

const redis = new Redis()
const ret = await redis.pipeline().get('foo').hget('hash', 'key').exec()
1reaction
luincommented, Sep 18, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphQL Join Monster Tutorial - YouTube
Learn how to add the Join Monster library to your GraphQL server. Join Monster helps optimize your GraphQL queries by only querying the ......
Read more >
On GraphQL-to-SQL
Tools like Join Monster (and Prisma Tools to a certain degree) need to somehow look at a GraphQL query, and decide what to...
Read more >
A GraphQL-to-SQL Query Execution Layer for Batch Data ...
What is Join Monster? Efficient query planning and data fetching for SQL. Use JOIN s and/or batched requests to retrieve all your data....
Read more >
awesome-graphql | Curated list of awesome lists
If you want to contribute to this list (please do), send me a pull request ... join-monster - A GraphQL-to-SQL query execution layer...
Read more >
6. Joining Objects - Join Monster
We need to add a field to our User , and tell joinMonster how to grab these ... that joinMonster will generate), the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found