Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple type of joins. #287

Open
wesselvdv opened this issue Feb 9, 2018 · 6 comments
Open

Support multiple type of joins. #287

wesselvdv opened this issue Feb 9, 2018 · 6 comments

Comments

@wesselvdv
Copy link

I am just starting to prototype a bit with this library and the first thing I notice is that it's using LEFT JOINs everywhere. I did take a look in the code and there's no support whatsoever for any other type than that. (hardcoded)

Is there a plan for support an INNER, RIGHT, FULL or CROSS (OUTER/LATERAL) join?

I understand that it's more taxing on the config side when defining your schema, but using a LEFT join for everything is not really efficient in most cases. I think that a preliminary support for an INNER join can be achieved with purely the type of the field that has the sqlJoin (GraphQLList vs a non list.)

@wtho
Copy link
Contributor

wtho commented Feb 25, 2018

My thoughts on alternative JOINs:

  • INNER JOIN:
    The way GraphQL works, it adds children for each level the query goes deeper. If one of the parents does not have the respective field or no objects to fill a list, it will just return an empty array or undefined field there, that is how GraphQL is specified and works (citation needed). With an INNER JOIN we would lose all parents that do not have the children set, see this query:
    { parent { someData children { some fields } } }

    If INNER JOIN would be applied, we would all parents without children, and also not get their someData.

  • OUTER JOIN:
    In the upper example, we would also get children, that are not assigned parents. How will we return them to GraphQL?

  • RIGHT JOIN:
    In most cases RIGHT JOIN is exchangable with LEFT JOIN, it might be useful in some SQL queries, but I do not see how a GraphQL-query could be translated in a way, that a RIGHT JOIN is required.

Maybe you can just give some examples where it would be useful to work with other JOINs.

@mposborne
Copy link

I too would like to see at least INNER JOIN available. Sometimes we do not want the parent to be available if there are no children.

@upasanadash
Copy link

Still.. Is there any possibility for inner join in join monster?

@upasanadash
Copy link

Hello....
I have not got any response

@namnm
Copy link

namnm commented Mar 15, 2019

@upasanadash I think you can fork and edit it yourself then have your own version to use for temporary if it's urgent.

@benmccann
Copy link
Contributor

I think the case where you need an inner join most is for specifying conditions. E.g. consider the following query from Hasura that fetches authors who have an article with a rating greater than four stars. I don't think you could do that without an inner join.

 query {
   author (where: {articles: {rating: {_gt: 4}}}) {
     id
     name
   }
 }

What would the approach be to do this in Join Monster? You could fetch all articles with ratings greater than four stars first, but that would be wasteful and potentially prohibitive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants