Skip to content

feat: add support for variable where criteria expressions #162

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 5 commits into from
Aug 24, 2019

Conversation

igdianov
Copy link
Collaborator

@igdianov igdianov commented Aug 17, 2019

This PR adds support for variable where criteria expressions, i.e. given

query($where: BooksCriteriaExpression) {
  Books (where: $where) {
    select {
      id(orderBy: ASC)
      title
      genre
    }
  }
}

with variables payload:

{
  "where": { 
    "genre": {
      "IN": ["NOVEL"]
    }
  }
}

the expected result will be:

{
  "data": {
    "Books": {
      "select": [
        {
          "id": 2,
          "title": "War and Peace",
          "genre": "NOVEL"
        },
        {
          "id": 3,
          "title": "Anna Karenina",
          "genre": "NOVEL"
        }
      ]
    }
  }
}

Fixes #126

@igdianov igdianov self-assigned this Aug 17, 2019
@igdianov
Copy link
Collaborator Author

@anotender Here is the first crack of the support passing where criteria expressions via variables. Feel free to try adding any test cases for your requirements...

@codecov
Copy link

codecov bot commented Aug 17, 2019

Codecov Report

Merging #162 into master will increase coverage by 0.52%.
The diff coverage is 83.33%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #162      +/-   ##
============================================
+ Coverage     68.12%   68.65%   +0.52%     
- Complexity      502      510       +8     
============================================
  Files            33       33              
  Lines          2576     2597      +21     
  Branches        431      431              
============================================
+ Hits           1755     1783      +28     
+ Misses          644      643       -1     
+ Partials        177      171       -6
Impacted Files Coverage Δ Complexity Δ
...a/query/schema/impl/QraphQLJpaBaseDataFetcher.java 74.95% <83.33%> (+0.97%) 160 <10> (+4) ⬆️
...hql/jpa/query/schema/impl/JpaPredicateBuilder.java 55.86% <0%> (+1.4%) 108% <0%> (+3%) ⬆️
...graphql/jpa/query/schema/impl/PredicateFilter.java 100% <0%> (+3.03%) 5% <0%> (+1%) ⬆️

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 8028d12...dd53c6e. Read the comment docs.

@anotender
Copy link
Contributor

@igdianov as for me, the changes look ok at the moment. Do you want to add something more?
And one more thing, what formatter should I use? As the default Intellij one seems to not format files as it should.

@igdianov
Copy link
Collaborator Author

@anotender Thanks! Everything looks good. I will merge and release this on the weekend. I am using STS 4.0 with custom formatter. I don't know how to export to IDEA. I will try to find a matching IDEA configuration.

@igdianov igdianov merged commit 5385a41 into master Aug 24, 2019
@igdianov igdianov deleted the igdianov-where-variable-criteria-expressions branch August 24, 2019 14:00
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.

Explore injecting where argument via variables
2 participants