-
Notifications
You must be signed in to change notification settings - Fork 55
distinct sql and ignore field in filters and sorting #95
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
distinct sql and ignore field in filters and sorting #95
Conversation
feat: add JPA @EmbeddedId support (introproventures#84)
merge master
Codecov Report
@@ Coverage Diff @@
## master #95 +/- ##
============================================
+ Coverage 65.44% 65.68% +0.24%
- Complexity 349 366 +17
============================================
Files 37 37
Lines 1962 2011 +49
Branches 291 296 +5
============================================
+ Hits 1284 1321 +37
- Misses 552 562 +10
- Partials 126 128 +2
Continue to review full report at Codecov.
|
...main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaQueryDataFetcher.java
Outdated
Show resolved
Hide resolved
...rc/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's configure default distinct with GraphJPASchemaBuilder method using Spring Boot configuration properties in starter, so folks can customize it via application properties or Java configuration.
...schema/src/test/java/com/introproventures/graphql/jpa/query/schema/GraphQLExecutorTests.java
Show resolved
Hide resolved
path: graphql - will clean I create options in GraphQLJpaQueryProperties and GraphQLSchemaBuilder config methods. |
aecc2b9
to
ac2ef24
Compare
rebase branch and fix ignore field in sub filterers. |
.../java/com/introproventures/graphql/jpa/query/schema/StarwarsSchemaBuildWithDistinctTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@miklemv Looks very good, but I think it makes more sense to put distinct argument inside select field. It is more logical place. I also wonder if the distinct argument will support variable bindings?
@igdianov |
@miklemv Sounds good! We can always refactor later if needed. Thank you! |
@chanhengseang3 Thish problem is hibernate level. I don'k know how distinc operation with models by fields. |
Now by default, the sql request with the distinct. I think this is not very good, better distict = false.
I added argument distict to request and set default distict = false. The default mode can be changed static setter. I'm not sure that distinct is needed in arguments.
Example request "{ Books(distinct: true) { select { genre } }}" return 5 record. This is misleading.
Added @GraphQLIgnoreFilter - prohibiting the use of field in filters.
Added @GraphQLIgnoreOrder - prohibiting the use of the field for sorting.
Using all fields in filters and sorting is dangerous, because this can create an unexpected strong load on the database if the field does not have an index. It seems to me that it is better to list the fields explicitly for sorting and filtering, but this will change the current behavior.