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

Nested relationship queries in where clauses #97

Closed
molexx opened this issue Mar 14, 2019 · 2 comments · Fixed by #108
Closed

Nested relationship queries in where clauses #97

molexx opened this issue Mar 14, 2019 · 2 comments · Fixed by #108

Comments

@molexx
Copy link
Contributor

molexx commented Mar 14, 2019

In a top level where clause you can only use a relationship of the first entity, after that you can only use simple attributes not relationships.

For example:

query {  
  Books(where: {
    author: {id: {EQ: 1}}
  }) {
    select {
      id
      title
      genre
      author {
        id
        name
      }
    }
  }
}

you can say 'author: {id: ' but you can't say 'author: {books: '.
Would it be possible to allow this please?

There are comments on this in #96.

@molexx
Copy link
Contributor Author

molexx commented Mar 14, 2019

RE #96 (comment), just thinking out loud on how this might work:

How about walking the tree in the where clause and storing up the defined predicates for entities that are not in the initial select. Then as the rest of the query/sub queries are built from the projection selection, check to see if there is a predicate stored for the current entity and apply it.
If, after all the nested queries are built, there are unapplied predicates remaining, generate clauses/sub queries to satisfy them.

?

@igdianov
Copy link
Collaborator

igdianov commented Apr 15, 2019

@molexx I have created a PR to add support for nested relationships in where criteria expressions. See: https://github.com/introproventures/graphql-jpa-query/pull/108/files#diff-52f280238db11c302ce9ac4f3fc76b15R777.

It only supports to one relationships for now. It also provides a workaround for nested embedded criteria expressions: #77

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

Successfully merging a pull request may close this issue.

2 participants