Skip to content

merge master #3

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 12 commits into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions .project

This file was deleted.

6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log

## 0.3.15-SNAPSHOT
## 0.3.17-SNAPSHOT
* fix: use embeddableType javaType to cache corresponding GraphQL type (#98) [ce4f85a](https://github.com/introproventures/graphql-jpa-query/commit/ce4f85a462d9c746d62c56e3f69be5beebd9d28c)
* feat: add where relation attributes criteria expressions (#96) [b296d8a](https://github.com/introproventures/graphql-jpa-query/commit/b296d8a2c9ad9d0a8b6b58d54f5cd6dcfded953f)
* chore: skip Docker plugin on release [2933500](https://github.com/introproventures/graphql-jpa-query/commit/2933500644bd6b781919a24c5583c6708f046a13)
* fix: spring.graphql.jpa.query.path must be specified (#94) [3094a6d](https://github.com/introproventures/graphql-jpa-query/commit/3094a6d130ecb5247dcafc312a03e3c6902bfada)
* fix: Configuration properties are ignored when merging bug (#88) [f838056](https://github.com/introproventures/graphql-jpa-query/commit/f838056009ca884d45e451b96a7a28dd8f9ea5a1)
* fix: upgrade to Spring Boot 2.1.3.RELEASE (#87) [ee0aa6c](https://github.com/introproventures/graphql-jpa-query/commit/ee0aa6c9ad5fead0f5a15e2133460fdebb9a0724)
* Refactor SchemaBuilder using Introspection (#86) [493f65d](https://github.com/introproventures/graphql-jpa-query/commit/493f65daa0e95d50a2ee8787af4444bcb365c2ed)
Expand Down
197 changes: 195 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ Will return:

Query Wrapper with Where Criteria Expressions
-------------------------------------
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.
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.

For Example:

Expand All @@ -173,7 +173,200 @@ Will return:
}
}

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.
Relation Attributes in Where Criteria Expressions:
----------------------------
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.

Given the following query with many-to-one relation with variables `{"authorId": 1 }` :

```
query($authorId: Long) {
Books(where: {
author: {id: {EQ: $authorId}}
}) {
select {
id
title
genre
author {
id
name
}
}
}
}
```

will result in

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

And given the following query with one-to-many relation:

```
query {
Authors(where: {
books: {genre: {IN: NOVEL}}
}) {
select {
id
name
books {
id
title
genre
}
}
}
}
```

will result in

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

It is possible to use compound criterias in where search expressions given:

```
query {
Authors(where: {
books: {
genre: {IN: NOVEL}
title: {LIKE: "War"}
}
}) {
select {
id
name
books {
id
title
genre
}
}
}
}
```

Will return filtered inner collection result:

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

It is also possible to filter inner collections as follows:

```
query {
Authors(where: {
books: {genre: {IN: NOVEL}}
}) {
select {
id
name
books(where: {title: {LIKE: "War"}}) {
id
title
genre
}
}
}
}
```

will result in

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

Collection Filtering
--------------------
Expand Down
2 changes: 1 addition & 1 deletion graphql-jpa-query-annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-dependencies</artifactId>
<version>0.3.15-SNAPSHOT</version>
<version>0.3.17-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-dependencies</relativePath>
</parent>

Expand Down
55 changes: 0 additions & 55 deletions graphql-jpa-query-autoconfigure/.classpath

This file was deleted.

7 changes: 6 additions & 1 deletion graphql-jpa-query-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-build</artifactId>
<version>0.3.15-SNAPSHOT</version>
<version>0.3.17-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>
<artifactId>graphql-jpa-query-autoconfigure</artifactId>
Expand All @@ -30,6 +30,11 @@
<artifactId>hibernate-validator</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,9 @@
import javax.validation.constraints.NotEmpty;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.validation.annotation.Validated;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.util.CollectionUtils;

import graphql.GraphQL;
Expand All @@ -17,6 +19,10 @@
@Configuration
@ConditionalOnClass(GraphQL.class)
@EnableConfigurationProperties(GraphQLJpaQueryProperties.class)
@PropertySources(value= {
@PropertySource("classpath:com/introproventures/graphql/jpa/query/boot/autoconfigure/default.properties"),
@PropertySource(value = "classpath:graphql-jpa-autoconfigure.properties", ignoreResourceNotFound = true)
})
public class GraphQLSchemaAutoConfiguration {

private final List<GraphQLSchemaConfigurer> graphQLSchemaConfigurers = new ArrayList<>();
Expand Down
Loading