GraphQL Java Tools

Tools to help map a GraphQL schema to existing Java objects.

License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.graphql-java
ArtifactId

ArtifactId

graphql-java-tools
Last Version

Last Version

5.2.4
Release Date

Release Date

Type

Type

jar
Description

Description

GraphQL Java Tools
Tools to help map a GraphQL schema to existing Java objects.
Project URL

Project URL

http://github.com/graphql-java/graphql-java-tools
Source Code Management

Source Code Management

http://github.com/graphql-java/graphql-java-tools

Download graphql-java-tools

How to add to project

<!-- https://jarcasting.com/artifacts/com.graphql-java/graphql-java-tools/ -->
<dependency>
    <groupId>com.graphql-java</groupId>
    <artifactId>graphql-java-tools</artifactId>
    <version>5.2.4</version>
</dependency>
// https://jarcasting.com/artifacts/com.graphql-java/graphql-java-tools/
implementation 'com.graphql-java:graphql-java-tools:5.2.4'
// https://jarcasting.com/artifacts/com.graphql-java/graphql-java-tools/
implementation ("com.graphql-java:graphql-java-tools:5.2.4")
'com.graphql-java:graphql-java-tools:jar:5.2.4'
<dependency org="com.graphql-java" name="graphql-java-tools" rev="5.2.4">
  <artifact name="graphql-java-tools" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.graphql-java', module='graphql-java-tools', version='5.2.4')
)
libraryDependencies += "com.graphql-java" % "graphql-java-tools" % "5.2.4"
[com.graphql-java/graphql-java-tools "5.2.4"]

Dependencies

compile (9)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib jar 1.2.60
com.graphql-java : graphql-java jar 9.2
com.fasterxml.jackson.core : jackson-core jar 2.9.6
com.fasterxml.jackson.module : jackson-module-kotlin jar 2.9.6
com.fasterxml.jackson.datatype : jackson-datatype-jdk8 jar 2.9.6
com.esotericsoftware : reflectasm jar 1.11.7
org.apache.commons : commons-lang3 jar 3.7
com.google.guava : guava jar 26.0-jre
org.slf4j : slf4j-api jar 1.7.25

provided (2)

Group / Artifact Type Version
org.springframework : spring-aop jar 4.3.11.RELEASE
org.javassist : javassist jar 3.23.1-GA

test (4)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar 1.1.7
org.spockframework : spock-core jar 1.0-groovy-2.4
cglib : cglib-nodep jar 3.1
org.objenesis : objenesis jar 2.1

Project Modules

There are no modules declared in this project.

GraphQL Java Tools

TravisCI Build Maven Central Chat on Spectrum

This library allows you to use the GraphQL schema language to build your graphql-java schema. Inspired by graphql-tools, it parses the given GraphQL schema and allows you to BYOO (bring your own object) to fill in the implementations. GraphQL Java Tools works well if you already have domain POJOs that hold your data (e.g. for RPC, ORM, REST, etc) by allowing you to map these "magically" to GraphQL objects.

GraphQL Java Tools aims for seamless integration with Java, but works for any JVM language. Try it with Kotlin!

We are looking for contributors!

Are you interested in improving our documentation, working on the codebase, reviewing PRs?

Reach out to us on Spectrum and join the team!

Quick start

Using Gradle

Set the Kotlin version in your gradle.properties:

kotlin.version=1.3.70

Add the dependency:

compile 'com.graphql-java-kickstart:graphql-java-tools:6.2.0'

Using Maven

Set the Kotlin version in your <properties> section:

<properties>
  <kotlin.version>1.3.70</kotlin.version>
</properties>

Add the dependency:

<dependency>
    <groupId>com.graphql-java-kickstart</groupId>
    <artifactId>graphql-java-tools</artifactId>
    <version>6.2.0</version>
</dependency>

Documentation

Take a look at our documentation for more details.

Why GraphQL Java Tools?

  • Schema First: GraphQL Java Tools allows you to write your schema in a simple, portable way using the GraphQL schema language instead of hard-to-read builders in code.
  • Minimal Boilerplate: It takes a lot of work to describe your GraphQL-Java objects manually, and quickly becomes unreadable. A few libraries exist to ease the boilerplate pain, including GraphQL-Java's built-in schema-first wiring, but none (so far) do type and datafetcher discovery.
  • Stateful Data Fetchers: If you're using an IOC container (like Spring), it's hard to wire up datafetchers that make use of beans you've already defined without a bunch of fragile configuration. GraphQL Java Tools allows you to register "Resolvers" for any type that can bring state along and use that to resolve fields.
  • Generated DataFetchers: GraphQL Java Tools automatically creates data fetchers for your fields that call the appropriate method on your java class. This means all you have to do to create a new field is add the field definition to your schema and add a corresponding method on your class.
  • Type->Class Discovery: GraphQL Java Tools starts from your root objects (Query, Mutation) and, as it's generating data fetchers for you, starts to learn about the classes you use for a certain GraphQL type.
  • Class Validation: Since there aren't any compile-time checks of the type->class relationship, GraphQL Java Tools will warn you if you provide classes/types that you don't need to, as well as erroring if you use the wrong Java class for a certain GraphQL type when it builds the schema.
  • Unit Testing: Since your GraphQL schema is independent of your data model, this makes your classes simple and extremely testable.

WARNING: NoClassDefFoundError when using Spring Boot

If you're using graphl-java-tools with Spring Boot version lower than 2.2 you need to set the kotlin.version in your Spring Boot project explicitly to version 1.3.70, because Spring Boot Starter parent currently overrides it with a 1.2.* version of Kotlin. graphql-java-tools requires 1.3.* however because of its coroutine support. If you don't override this version you will run into a NoClassDefFoundError.

Spring Boot team has indicated the Kotlin version will be upgraded to 1.3 in Spring Boot 2.2.

com.graphql-java

GraphQL Java

GraphQL server implementation for Java/JVM

Versions

Version
5.2.4
5.2.3
5.2.0
5.1.0
5.0.0
4.3.0
4.2.0
4.1.2
4.1.1
4.1.0
4.0.2
4.0.1
4.0.0
3.2.1
3.2.0
3.1.3
3.1.2
3.1.0
3.0.2
3.0.1
3.0.0
2.3.0
2.2.0
2.1.3