Skip to content

fix: compound nested relationship criteria expressions #121

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

Merged
merged 3 commits into from
Apr 27, 2019

Conversation

igdianov
Copy link
Collaborator

@igdianov igdianov commented Apr 27, 2019

The PR fixes problem mapping GraphQL query with nested relation criteria expressions using nested AND: { OR: { expressions } } into JPQL, i.e.

query {
  Authors(where: {
    books: {
      author: { name: {LIKE:"Leo"} }
      AND: {
        OR: {
          id: {EQ: 2}
          title: {LIKE: "Anna"}
        }
      }
    }
  }) {
    select {
      id
      name
      books {
        id
        title
        genre
      }
    }
  }
}  

Should produce the following Hibernate query:

    select
        author0_.id as id1_0_0_,
        books1_.id as id1_2_1_,
        author0_.genre as genre2_0_0_,
        author0_.name as name3_0_0_,
        books1_.author_id as author_i6_2_1_,
        books1_.description as descript2_2_1_,
        books1_.genre as genre3_2_1_,
        books1_.publicationDate as publicat4_2_1_,
        books1_.title as title5_2_1_,
        books1_.author_id as author_i6_2_0__,
        books1_.id as id1_2_0__ 
    from
        Author author0_ 
    inner join
        Book books1_ 
            on author0_.id=books1_.author_id 
    inner join
        Author author2_ 
            on books1_.author_id=author2_.id 
    where
        (
            books1_.id=2 
            or lower(books1_.title) like ?
        ) 
        and (
            lower(author2_.name) like ?
        ) 
    order by
        author0_.id asc,
        books1_.id asc

@igdianov igdianov self-assigned this Apr 27, 2019
@igdianov igdianov added the bug label Apr 27, 2019
@codecov
Copy link

codecov bot commented Apr 27, 2019

Codecov Report

Merging #121 into master will increase coverage by 0.04%.
The diff coverage is 91.66%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #121      +/-   ##
============================================
+ Coverage     66.37%   66.42%   +0.04%     
- Complexity      381      383       +2     
============================================
  Files            34       34              
  Lines          2031     2031              
  Branches        302      301       -1     
============================================
+ Hits           1348     1349       +1     
  Misses          552      552              
+ Partials        131      130       -1
Impacted Files Coverage Δ Complexity Δ
...a/query/schema/impl/QraphQLJpaBaseDataFetcher.java 73.06% <91.66%> (+0.28%) 117 <6> (+2) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update efc5278...2952265. Read the comment docs.

@igdianov igdianov merged commit af279d9 into master Apr 27, 2019
@igdianov igdianov deleted the igdianov-fix-relation-predicates branch April 27, 2019 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant