Skip to content

feat: support nested relationships in where criteria expressions #108

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 14 commits into from
Apr 22, 2019

Conversation

igdianov
Copy link
Collaborator

@igdianov igdianov commented Apr 15, 2019

Given the following query:

  Authors(where: {
    books: {
      author: {
        name: {LIKE: "Leo"}
      }
    }
  }) {
    select {
      id
      name
      books {
        id
        title
        genre
      }
    }
  }

Expected result:

{
  "data": {
    "Authors": {
      "select": [
        {
          "id": 1,
          "name": "Leo Tolstoy",
          "books": [
            {
              "id": 2,
              "title": "War and Peace",
              "genre": "NOVEL",
            },
            {
              "id": 3,
              "title": "Anna Karenina",
              "genre": "NOVEL",
            }
          ]
        }
      ]
    }
  }
}

And collection filtering in nested relationships :

  Books(where: {
    title:{LIKE: "War"}
    author: {
      name:{LIKE: "Leo"}
      books: {title: {LIKE: "Anna"}}
    }
  }) {
    select {
      id
      title
      genre
      author {
        id
        name
        books {
          id
          title
          genre
        }
      }
    }
  }

Will return:

{
  "data": {
    "Books": {
      "select": [
        {
          "id": 2,
          "title": "War and Peace",
          "genre": "NOVEL",
          "author": {
            "id": 1,
            "name": "Leo Tolstoy",
            "books": [
              {
                "id": 3,
                "title": "Anna Karenina",
                "genre": "NOVEL"
              }
            ]
          }
        }
      ]
    }
  }
}

Fixes #97

Fixes #77

@igdianov igdianov self-assigned this Apr 15, 2019
@codecov
Copy link

codecov bot commented Apr 15, 2019

Codecov Report

Merging #108 into master will decrease coverage by 0.16%.
The diff coverage is 63.63%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #108      +/-   ##
============================================
- Coverage     65.75%   65.59%   -0.17%     
- Complexity      366      369       +3     
============================================
  Files            37       39       +2     
  Lines          2015     2046      +31     
  Branches        297      300       +3     
============================================
+ Hits           1325     1342      +17     
- Misses          562      576      +14     
  Partials        128      128
Impacted Files Coverage Δ Complexity Δ
...ventures/graphql/jpa/query/example/books/Book.java 0% <ø> (ø) 0 <0> (ø) ⬇️
...phql/jpa/query/example/starwars/DroidFunction.java 0% <0%> (ø) 0 <0> (?)
...phql/jpa/query/example/starwars/DroidFunction.java 0% <0%> (ø) 0 <0> (?)
...ures/graphql/jpa/query/example/starwars/Droid.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...ures/graphql/jpa/query/example/starwars/Droid.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java 86.84% <100%> (+0.39%) 106 <4> (+3) ⬆️
...a/query/schema/impl/QraphQLJpaBaseDataFetcher.java 70.89% <40%> (-1.17%) 111 <0> (ø)

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 8e9d409...a658647. Read the comment docs.

@codecov
Copy link

codecov bot commented Apr 15, 2019

Codecov Report

Merging #108 into master will increase coverage by 0.08%.
The diff coverage is 70%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #108      +/-   ##
============================================
+ Coverage     66.37%   66.45%   +0.08%     
- Complexity      372      382      +10     
============================================
  Files            37       39       +2     
  Lines          2034     2054      +20     
  Branches        302      302              
============================================
+ Hits           1350     1365      +15     
- Misses          552      558       +6     
+ Partials        132      131       -1
Impacted Files Coverage Δ Complexity Δ
...a/query/schema/impl/QraphQLJpaBaseDataFetcher.java 72.77% <ø> (+0.85%) 115 <0> (+2) ⬆️
...ntures/graphql/jpa/query/example/books/Author.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...phql/jpa/query/example/starwars/DroidFunction.java 0% <0%> (ø) 0 <0> (?)
...phql/jpa/query/example/starwars/DroidFunction.java 0% <0%> (ø) 0 <0> (?)
...ventures/graphql/jpa/query/example/books/Book.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...ures/graphql/jpa/query/example/starwars/Droid.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...ures/graphql/jpa/query/example/starwars/Droid.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...ry/schema/impl/GraphQLJpaOneToManyDataFetcher.java 73.68% <100%> (ø) 13 <0> (ø) ⬇️
...jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java 87.27% <100%> (+0.43%) 113 <7> (+8) ⬆️
... and 3 more

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 3f9704b...bd9d667. Read the comment docs.

@igdianov igdianov changed the title feat: support many-to-one relation criteria expression feat: support nested relationships in where criteria expressions Apr 15, 2019
@molexx
Copy link
Contributor

molexx commented Apr 15, 2019

Great thanks, will try the branch on our project!

@igdianov igdianov force-pushed the igdianov-many-to-one-relation-criteria branch from 630a684 to c65590e Compare April 16, 2019 02:04
@igdianov igdianov force-pushed the igdianov-many-to-one-relation-criteria branch from c65590e to caa2df8 Compare April 20, 2019 04:45
@igdianov igdianov force-pushed the igdianov-many-to-one-relation-criteria branch from caa2df8 to bd9d667 Compare April 22, 2019 20:55
@igdianov igdianov merged commit b05c246 into master Apr 22, 2019
@igdianov igdianov deleted the igdianov-many-to-one-relation-criteria branch April 22, 2019 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nested relationship queries in where clauses Bug: 'where' filter on nested many-to-one not working
2 participants