Skip to content

Commit 18ec562

Browse files
authored
Merge pull request #3 from introproventures/master
merge master
2 parents 034aca1 + 4c8bf31 commit 18ec562

File tree

45 files changed

+1284
-444
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1284
-444
lines changed

.project

Lines changed: 0 additions & 17 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Change Log
22

3-
## 0.3.15-SNAPSHOT
3+
## 0.3.17-SNAPSHOT
4+
* fix: use embeddableType javaType to cache corresponding GraphQL type (#98) [ce4f85a](https://github.com/introproventures/graphql-jpa-query/commit/ce4f85a462d9c746d62c56e3f69be5beebd9d28c)
5+
* feat: add where relation attributes criteria expressions (#96) [b296d8a](https://github.com/introproventures/graphql-jpa-query/commit/b296d8a2c9ad9d0a8b6b58d54f5cd6dcfded953f)
6+
* chore: skip Docker plugin on release [2933500](https://github.com/introproventures/graphql-jpa-query/commit/2933500644bd6b781919a24c5583c6708f046a13)
7+
* fix: spring.graphql.jpa.query.path must be specified (#94) [3094a6d](https://github.com/introproventures/graphql-jpa-query/commit/3094a6d130ecb5247dcafc312a03e3c6902bfada)
48
* fix: Configuration properties are ignored when merging bug (#88) [f838056](https://github.com/introproventures/graphql-jpa-query/commit/f838056009ca884d45e451b96a7a28dd8f9ea5a1)
59
* fix: upgrade to Spring Boot 2.1.3.RELEASE (#87) [ee0aa6c](https://github.com/introproventures/graphql-jpa-query/commit/ee0aa6c9ad5fead0f5a15e2133460fdebb9a0724)
610
* Refactor SchemaBuilder using Introspection (#86) [493f65d](https://github.com/introproventures/graphql-jpa-query/commit/493f65daa0e95d50a2ee8787af4444bcb365c2ed)

README.md

Lines changed: 195 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Will return:
150150

151151
Query Wrapper with Where Criteria Expressions
152152
-------------------------------------
153-
This library supports flexible type safe criteria expressions with user-friendly SQL query syntax semantics using `where` arguments and `select` field to specify the entity graph query with entiy attribute names as a combination of logical expressions like OR, AND, EQ, NE, GT, GE, LT, LR, IN, NIN, IS_NULL, NOT_NULL, BETWEEN, NOT_BETWEEN.
153+
This library supports flexible type safe criteria expressions with user-friendly SQL query syntax semantics using `where` arguments and `select` field to specify the entity graph query with entiy attribute names as a combination of logical expressions like EQ, NE, GT, GE, LT, LR, IN, NIN, IS_NULL, NOT_NULL, BETWEEN, NOT_BETWEEN. You can use logical AND/OR combinations in SQL criteria expressions to specify complex criterias to fetch your data from SQL database. If you omit, where argument, all entities will be returned.
154154

155155
For Example:
156156

@@ -173,7 +173,200 @@ Will return:
173173
}
174174
}
175175

176-
You can use familiar SQL criteria expressions to specify complex criterias to fetch your data from SQL database. If you omit, where argument, all entities will be returned.
176+
Relation Attributes in Where Criteria Expressions:
177+
----------------------------
178+
It is also possible to specify complex filters using many-to-one and one-to-many entity attributes in where criteria expressions with variable parameter bindings, i.e.
179+
180+
Given the following query with many-to-one relation with variables `{"authorId": 1 }` :
181+
182+
```
183+
query($authorId: Long) {
184+
Books(where: {
185+
author: {id: {EQ: $authorId}}
186+
}) {
187+
select {
188+
id
189+
title
190+
genre
191+
author {
192+
id
193+
name
194+
}
195+
}
196+
}
197+
}
198+
```
199+
200+
will result in
201+
202+
```
203+
{
204+
"data": {
205+
"Books": {
206+
"select": [
207+
{
208+
"id": 2,
209+
"title": "War and Peace",
210+
"genre": "NOVEL",
211+
"author": {
212+
"id": 1,
213+
"name": "Leo Tolstoy"
214+
}
215+
},
216+
{
217+
"id": 3,
218+
"title": "Anna Karenina",
219+
"genre": "NOVEL",
220+
"author": {
221+
"id": 1,
222+
"name": "Leo Tolstoy"
223+
}
224+
}
225+
]
226+
}
227+
}
228+
}
229+
```
230+
231+
And given the following query with one-to-many relation:
232+
233+
```
234+
query {
235+
Authors(where: {
236+
books: {genre: {IN: NOVEL}}
237+
}) {
238+
select {
239+
id
240+
name
241+
books {
242+
id
243+
title
244+
genre
245+
}
246+
}
247+
}
248+
}
249+
```
250+
251+
will result in
252+
253+
```
254+
{
255+
"data": {
256+
"Authors": {
257+
"select": [
258+
{
259+
"id": 1,
260+
"name": "Leo Tolstoy",
261+
"books": [
262+
{
263+
"id": 2,
264+
"title": "War and Peace",
265+
"genre": "NOVEL"
266+
},
267+
{
268+
"id": 3,
269+
"title": "Anna Karenina",
270+
"genre": "NOVEL"
271+
}
272+
]
273+
}
274+
]
275+
}
276+
}
277+
}
278+
```
279+
280+
It is possible to use compound criterias in where search expressions given:
281+
282+
```
283+
query {
284+
Authors(where: {
285+
books: {
286+
genre: {IN: NOVEL}
287+
title: {LIKE: "War"}
288+
}
289+
}) {
290+
select {
291+
id
292+
name
293+
books {
294+
id
295+
title
296+
genre
297+
}
298+
}
299+
}
300+
}
301+
```
302+
303+
Will return filtered inner collection result:
304+
305+
```
306+
{
307+
"data": {
308+
"Authors": {
309+
"select": [
310+
{
311+
"id": 1,
312+
"name": "Leo Tolstoy",
313+
"books": [
314+
{
315+
"id": 2,
316+
"title": "War and Peace",
317+
"genre": "NOVEL"
318+
}
319+
]
320+
}
321+
]
322+
}
323+
}
324+
}
325+
```
326+
327+
It is also possible to filter inner collections as follows:
328+
329+
```
330+
query {
331+
Authors(where: {
332+
books: {genre: {IN: NOVEL}}
333+
}) {
334+
select {
335+
id
336+
name
337+
books(where: {title: {LIKE: "War"}}) {
338+
id
339+
title
340+
genre
341+
}
342+
}
343+
}
344+
}
345+
```
346+
347+
will result in
348+
349+
```
350+
{
351+
"data": {
352+
"Authors": {
353+
"select": [
354+
{
355+
"id": 1,
356+
"name": "Leo Tolstoy",
357+
"books": [
358+
{
359+
"id": 2,
360+
"title": "War and Peace",
361+
"genre": "NOVEL"
362+
}
363+
]
364+
}
365+
]
366+
}
367+
}
368+
}
369+
```
177370

178371
Collection Filtering
179372
--------------------

graphql-jpa-query-annotations/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.introproventures</groupId>
88
<artifactId>graphql-jpa-query-dependencies</artifactId>
9-
<version>0.3.15-SNAPSHOT</version>
9+
<version>0.3.17-SNAPSHOT</version>
1010
<relativePath>../graphql-jpa-query-dependencies</relativePath>
1111
</parent>
1212

graphql-jpa-query-autoconfigure/.classpath

Lines changed: 0 additions & 55 deletions
This file was deleted.

graphql-jpa-query-autoconfigure/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>com.introproventures</groupId>
55
<artifactId>graphql-jpa-query-build</artifactId>
6-
<version>0.3.15-SNAPSHOT</version>
6+
<version>0.3.17-SNAPSHOT</version>
77
<relativePath>../graphql-jpa-query-build</relativePath>
88
</parent>
99
<artifactId>graphql-jpa-query-autoconfigure</artifactId>
@@ -30,6 +30,11 @@
3030
<artifactId>hibernate-validator</artifactId>
3131
<scope>test</scope>
3232
</dependency>
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-configuration-processor</artifactId>
36+
<optional>true</optional>
37+
</dependency>
3338
</dependencies>
3439

3540
</project>

graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLJpaQueryProperties.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,9 @@
1818
import javax.validation.constraints.NotEmpty;
1919

2020
import org.springframework.boot.context.properties.ConfigurationProperties;
21-
import org.springframework.context.annotation.PropertySource;
22-
import org.springframework.context.annotation.PropertySources;
2321
import org.springframework.validation.annotation.Validated;
2422

2523
@ConfigurationProperties(prefix="spring.graphql.jpa.query")
26-
@PropertySources(value= {
27-
@PropertySource("classpath:/com/introproventures/graphql/jpa/query/boot/autoconfigure/default.properties"),
28-
@PropertySource(value = "classpath:graphql-jpa-autoconfigure.properties", ignoreResourceNotFound = true)
29-
})
3024
@Validated
3125
public class GraphQLJpaQueryProperties {
3226

graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaAutoConfiguration.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import org.springframework.boot.context.properties.EnableConfigurationProperties;
1010
import org.springframework.context.annotation.Bean;
1111
import org.springframework.context.annotation.Configuration;
12+
import org.springframework.context.annotation.PropertySource;
13+
import org.springframework.context.annotation.PropertySources;
1214
import org.springframework.util.CollectionUtils;
1315

1416
import graphql.GraphQL;
@@ -17,6 +19,10 @@
1719
@Configuration
1820
@ConditionalOnClass(GraphQL.class)
1921
@EnableConfigurationProperties(GraphQLJpaQueryProperties.class)
22+
@PropertySources(value= {
23+
@PropertySource("classpath:com/introproventures/graphql/jpa/query/boot/autoconfigure/default.properties"),
24+
@PropertySource(value = "classpath:graphql-jpa-autoconfigure.properties", ignoreResourceNotFound = true)
25+
})
2026
public class GraphQLSchemaAutoConfiguration {
2127

2228
private final List<GraphQLSchemaConfigurer> graphQLSchemaConfigurers = new ArrayList<>();

0 commit comments

Comments
 (0)