com.daikit:spring-boot-starter-data-graphql

Spring boot starter for GraphQL endpoint over a JPA persistence layer based on java-data-graphql library.

License

License

Categories

Categories

Spring Boot Container Microservices Data
GroupId

GroupId

com.daikit
ArtifactId

ArtifactId

spring-boot-starter-data-graphql-jpa
Last Version

Last Version

1.11
Release Date

Release Date

Type

Type

jar
Description

Description

com.daikit:spring-boot-starter-data-graphql
Spring boot starter for GraphQL endpoint over a JPA persistence layer based on java-data-graphql library.
Project URL

Project URL

https://github.com/tcaselli/spring-boot-starter-data-graphql-jpa
Source Code Management

Source Code Management

https://github.com/tcaselli/spring-boot-starter-data-graphql-jpa

Download spring-boot-starter-data-graphql-jpa

How to add to project

<!-- https://jarcasting.com/artifacts/com.daikit/spring-boot-starter-data-graphql-jpa/ -->
<dependency>
    <groupId>com.daikit</groupId>
    <artifactId>spring-boot-starter-data-graphql-jpa</artifactId>
    <version>1.11</version>
</dependency>
// https://jarcasting.com/artifacts/com.daikit/spring-boot-starter-data-graphql-jpa/
implementation 'com.daikit:spring-boot-starter-data-graphql-jpa:1.11'
// https://jarcasting.com/artifacts/com.daikit/spring-boot-starter-data-graphql-jpa/
implementation ("com.daikit:spring-boot-starter-data-graphql-jpa:1.11")
'com.daikit:spring-boot-starter-data-graphql-jpa:jar:1.11'
<dependency org="com.daikit" name="spring-boot-starter-data-graphql-jpa" rev="1.11">
  <artifact name="spring-boot-starter-data-graphql-jpa" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.daikit', module='spring-boot-starter-data-graphql-jpa', version='1.11')
)
libraryDependencies += "com.daikit" % "spring-boot-starter-data-graphql-jpa" % "1.11"
[com.daikit/spring-boot-starter-data-graphql-jpa "1.11"]

Dependencies

compile (9)

Group / Artifact Type Version
com.daikit : spring-boot-starter-data-graphql jar 1.12
org.reflections : reflections jar 0.9.10
org.springframework.data : spring-data-jpa jar
org.springframework : spring-tx jar
org.springframework : spring-orm jar
com.querydsl : querydsl-apt jar
com.querydsl : querydsl-jpa jar
org.hibernate : hibernate-envers jar
org.hibernate : hibernate-core jar

Project Modules

There are no modules declared in this project.

Spring boot starter data graphql JPA

License

Documentation

Spring boot starter for GraphQL endpoint over a JPA persistence layer based on java-data-graphql library.
See spring-data-graphql-jpa-demo for an example of usage.

The goal of this starter is to make the glue between a GraphQL engine and a SQL database. We have to automatically convert GraphQL queries and mutations to database SQL queries.
To achieve this goal this starter is using these third party libraries :

Configuration properties

When creating a GQLExecutor, you will have to provide a com.daikit.graphql.config.GQLSchemaConfig. The default implementation takes these properties default values. You can override these properties in your application.properties file.

# the base package where your querydsl entity paths will be generated
spring.data.graphql.jpa.querydsl-parent-packages=com.daikit

QueryDSL entity paths

In order to be able to automatically convert GraphQL queries to JPA queries, all entities referenced in GraphQL schema must have a corresponding queryDSL entityPath.
These entityPaths can be generated thanks to apt-maven-plugin (see demo project for example).

Spring data JPA repositories

In order to be able to automatically convert GraphQL queries to JPA queries, all entities referenced in GraphQL schema must have a corresponding spring data repository interface extending com.daikit.graphql.spring.jpa.repository.IEntityRepository (see demo project for example).

The persistence registry

The persistence registry (extending com.daikit.graphql.spring.jpa.service.IPersistenceRegistry) with its default implementation com.daikit.graphql.spring.jpa.service.DefaultPersistenceRegistry (which can be overridden) is registering all entity paths and repositories and provide simple access by entity class for the entity service.

The entity service

The entity service (extending com.daikit.graphql.spring.jpa.service.IEntityService) is providing methods accessible by GraphQL data fetchers for CRUD operations on any entity types. It uses the persistence registry underthehood.

Custom hibernate user types

When you want to store data as JSON in a SQL column you need to use hibernate custom org.hibernate.usertype.UserType. These data can then be available in the GraphQL layer thanks to "embedded entities" (set the entity meta data as embedded when building the GraphQL meta model).
In order to simplify the creation/update of these embedded entities you can extend some custom user types that will simplify your life. (See com.daikit.graphql.spring.jpa.usertype.AbstractJsonUserType and com.daikit.graphql.spring.jpa.usertype.AbstractJsonCollectionUserType and extending classes for for info) (see demo project for example)

Where can I get the latest release?

You can check latest version and pull it from the central Maven repositories:

With maven

<dependency>
    <groupId>com.daikit</groupId>
    <artifactId>spring-boot-starter-data-graphql-jpa</artifactId>
    <version>x.x</version>
</dependency>

Or with gradle

compile group: 'com.daikit', name: 'spring-boot-starter-data-graphql-jpa', version: 'x.x'

Contributing

We accept Pull Requests via GitHub. There are some guidelines which will make applying PRs easier for us:

  • No spaces :) Please use tabs for indentation.
  • Respect the code style.
  • Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change.
  • Provide JUnit tests for your changes and make sure your changes don't break any existing tests by running mvn clean test.

License

This code is under the Apache Licence v2.

Versions

Version
1.11
1.10
1.8
1.7
1.6
1.5
1.3
1.2
1.1
1.0