Skip to content

Commit

Permalink
[#1404, #1405] Add JSONB integration and make sure that GraphQL mutat…
Browse files Browse the repository at this point in the history
…ions work
  • Loading branch information
beikov committed Dec 27, 2021
1 parent 542a71a commit 46c0b85
Show file tree
Hide file tree
Showing 135 changed files with 6,776 additions and 423 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Not yet released
* Add `PERCENTILE_CONT`, `PERCENTILE_DISC` and `MODE` ordered set-aggregate functions
* Add JPA Criteria support for aggregate `FILTER` clause, window functions and ordered set aggregate functions
* Fire `EntityViewConfiguration` as event in Quarkus extension boot like in the CDI integration to allow customization
* Add Spring SPQR example application showcasing how GraphQL mutations can be used
* Add JSONB integration for deserializing entity views
* Add Spring SPQR integration and example application
* Add examples for SPQR, DGS and MicroProfile GraphQL showcasing how GraphQL mutations can be used

### Bug fixes

Expand All @@ -24,10 +26,12 @@ Not yet released
* Add `getById` implementation as needed by Spring Data 2.5 to the integration
* Ensure stream/iteration processing of results works with entity views containing no collections
* Fix support for flushing flat view collections with read-only declared and updatable subview types
* Ensure pending inserts for tables targeted by foreign keys by custom insert/update DML are flushed

### Backwards-incompatible changes

* Properly implement the `getOne` semantics to return a reference instead of querying an instance
* Split JAX-RS integration into JAX-RS for Jackson and JAX-RS for JSONB integrations

## 1.6.3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
<suppress checks="." files="[\\/]com[\\/]blazebit[\\/]persistence[\\/]spring[\\/]data[\\/]webflux[\\/]impl[\\/]SortHandlerMethodArgumentResolver\.java$"/>
<suppress checks="." files="[\\/]com[\\/]blazebit[\\/]persistence[\\/]spring[\\/]data[\\/]webflux[\\/]impl[\\/]SortArgumentResolver\.java$"/>

<suppress checks="." files="[\\/]com[\\/]blazebit[\\/]persistence[\\/]integration[\\/]jsonb[\\/]jsonstructure[\\/].*\.java$"/>

<!-- The implementation, testsuite and examples don't have to fit our Javadoc requirements -->
<suppress checks="JavadocPackage" files="[\\/](parser|impl|integration|testsuite|processor|examples|org.springframework)[\\/].*\.java$"/>
<suppress checks="JavadocMethod" files="[\\/](parser|impl|integration|testsuite|processor|examples|org.springframework)[\\/].*\.java$"/>
Expand Down
44 changes: 43 additions & 1 deletion dist/bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,29 @@
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jaxrs</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jaxrs-jackson</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jaxrs-jsonb</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jaxrs-jakarta</artifactId>
<artifactId>blaze-persistence-integration-jaxrs-jackson-jakarta</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jaxrs-jsonb-jakarta</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
Expand All @@ -384,6 +402,18 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jsonb</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jsonb-jakarta</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-graphql</artifactId>
Expand All @@ -396,6 +426,18 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-graphql-spqr</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-graphql-spqr-jakarta</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-quarkus</artifactId>
Expand Down
16 changes: 16 additions & 0 deletions dist/full/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-graphql</artifactId>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-graphql-spqr</artifactId>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-spring-hateoas-webmvc</artifactId>
Expand All @@ -207,10 +211,22 @@
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jackson</artifactId>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jsonb</artifactId>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jaxrs-jackson</artifactId>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jaxrs-jsonb</artifactId>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-quarkus</artifactId>
Expand Down
9 changes: 3 additions & 6 deletions dist/full/src/main/distribution/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,9 @@
<include>com.blazebit:blaze-persistence-integration-entity-view-*</include>
<include>com.blazebit:blaze-persistence-integration-spring-*</include>
<include>com.blazebit:blaze-persistence-integration-deltaspike-data-*</include>
<include>com.blazebit:blaze-persistence-integration-jaxrs</include>
<include>com.blazebit:blaze-persistence-integration-jaxrs-jakarta</include>
<include>com.blazebit:blaze-persistence-integration-jackson</include>
<include>com.blazebit:blaze-persistence-integration-jackson-jakarta</include>
<include>com.blazebit:blaze-persistence-integration-graphql</include>
<include>com.blazebit:blaze-persistence-integration-graphql-jakarta</include>
<include>com.blazebit:blaze-persistence-integration-jaxrs*</include>
<include>com.blazebit:blaze-persistence-integration-jackson*</include>
<include>com.blazebit:blaze-persistence-integration-graphql*</include>
</includes>
<outputFileNameMapping>${artifact.artifactId}-${project.version}.${artifact.extension}</outputFileNameMapping>
<outputDirectory>lib/integration/entity-view</outputDirectory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ or if you are using Jakarta JPA
----
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-graphql</artifactId>
<artifactId>blaze-persistence-integration-graphql-jakarta</artifactId>
<version>${blaze-persistence.version}</version>
<scope>compile</scope>
</dependency>
Expand Down Expand Up @@ -238,6 +238,86 @@ public class CatFetcher {

For a full example see the following https://github.com/Blazebit/blaze-persistence/blob/master/examples/spring-data-graphql/[example project].

==== SPQR setup

To use the SPQR GraphQL integration you need the following Maven dependencies:

[source,xml]
----
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-graphql-spqr</artifactId>
<version>${blaze-persistence.version}</version>
<scope>compile</scope>
</dependency>
----

or if you are using Jakarta JPA

[source,xml]
----
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-graphql-spqr-jakarta</artifactId>
<version>${blaze-persistence.version}</version>
<scope>compile</scope>
</dependency>
----

The SPQR configuration is very simple and since the framework is fully declarative, you don't need a dedicated GraphQL schema definition.

[source,java]
----
@Configuration
public class GraphQLProvider {
@Autowired
EntityViewManager evm;
@Autowired
GraphQLSchema graphQLSchema;
private GraphQLEntityViewSupport graphQLEntityViewSupport;
@PostConstruct
public void init() {
GraphQLEntityViewSupportFactory graphQLEntityViewSupportFactory = new GraphQLEntityViewSupportFactory(false, false);
graphQLEntityViewSupportFactory.setImplementRelayNode(false);
graphQLEntityViewSupportFactory.setDefineRelayNodeIfNotExist(false);
this.graphQLEntityViewSupport = graphQLEntityViewSupportFactory.create(graphQLSchema, evm);
}
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
@Lazy(false)
public GraphQLEntityViewSupport graphQLEntityViewSupport() {
return graphQLEntityViewSupport;
}
}
----

Next, one needs to define a `DataFetcher` for the defined query `catById` like so

[source,java]
----
@Component
@GraphQLApi
public class CatFetcher {
@Autowired
CatViewRepository repository;
@Autowired
GraphQLEntityViewSupport graphQLEntityViewSupport;
@GraphQLQuery
public CatWithOwnerView catById(@GraphQLArgument(name = "id") Long id, @GraphQLEnvironment ResolutionEnvironment env) {
return repository.findById(graphQLEntityViewSupport.createSetting(env.dataFetchingEnvironment), id);
}
}
----

For a full example see the following https://github.com/Blazebit/blaze-persistence/blob/master/examples/spring-data-graphql/[example project].

==== MicroProfile GraphQL - SmallRye

MicroProfile GraphQL (version 1.1 at the time of writing) has a completely different approach, as it is completely annotation based.
Expand Down Expand Up @@ -575,4 +655,5 @@ For a full example see one of the following example projects:

* https://github.com/Blazebit/blaze-persistence/blob/master/examples/spring-data-graphql/[Plain graphql-java]
* https://github.com/Blazebit/blaze-persistence/blob/master/examples/spring-data-dgs/[Netflix DGS]
* https://github.com/Blazebit/blaze-persistence/blob/master/examples/microprofile-graphql/[MicroProfile GraphQL]
* https://github.com/Blazebit/blaze-persistence/blob/master/examples/microprofile-graphql/[MicroProfile GraphQL]
* https://github.com/Blazebit/blaze-persistence/blob/master/examples/spring-data-spqr/[SPQR]
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[[jaxrs-integration]]
== JAX-RS integration

The JAX-RS integration provides `MessageBodyReader` and `ParamConverter` implementations to integrate the following serialization integrations with JAX-RS
The JAX-RS integration module serves as the API which contains the `@EntityViewId` annotation.
The `MessageBodyReader` and `ParamConverter` implementations to integrate serialization frameworks with JAX-RS are available for

* <<jackson-integration,Jackson integration>>
* <<jsonb-integration,JSONB integration>>
* _At some point there will also be support for JAXB_

The integration is discovered automatically through the `javax.ws.rs.ext.Providers` ServiceLoader contract. Simply putting the artifact on the classpath is enough for the integration.
Expand All @@ -17,7 +19,7 @@ To use the Jackson integration directly you need the following Maven dependencie
----
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jaxrs</artifactId>
<artifactId>blaze-persistence-integration-jaxrs-jackson</artifactId>
<version>${blaze-persistence.version}</version>
<scope>runtime</scope>
</dependency>
Expand All @@ -29,7 +31,31 @@ or if you are using Jakarta JPA
----
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jaxrs-jakarta</artifactId>
<artifactId>blaze-persistence-integration-jaxrs-jackson-jakarta</artifactId>
<version>${blaze-persistence.version}</version>
<scope>runtime</scope>
</dependency>
----

To use the JSONB integration directly you need the following Maven dependencies:

[source,xml]
----
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jaxrs-jsonb</artifactId>
<version>${blaze-persistence.version}</version>
<scope>runtime</scope>
</dependency>
----

or if you are using Jakarta JPA

[source,xml]
----
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-jaxrs-jsonb-jakarta</artifactId>
<version>${blaze-persistence.version}</version>
<scope>runtime</scope>
</dependency>
Expand Down
Loading

0 comments on commit 46c0b85

Please sign in to comment.