This project integrates GraphQL Java into Spring/Spring Boot, by enabling query execution via HTTP.
While the GraphQL Specification itself doesn't specify any transport protocol there is a quasi standard how to do it described here and this project follows this quasi standard.
Goals / Design:
- Just HTTP JSON: the current focus is on HTTP execution via JSON.
- Minimal Dependencies: the only dependencies are GraphQL Java and Spring projects (including Jackson for JSON handling).
- No additional abstraction layer on top of GraphQL Java: GraphQL Java is meant to be used directly.
As outlined in https://graphql.org/learn/serving-over-http this project supports:
- GET request with
query,operationNameandvariablesparameters. The variable parameters are json encoded - POST request with body
application/jsonand keysquery(string),operationName(string) andvariables(map).
Both produce application/json.
The Spring Boot Starter artifact provides a HTTP endpoint on ${graphql.url} with the default value "/graphql" just by being on the classpath.
The only requirement is to have a Bean of type graphql.GraphQL available.
Add the following dependency to your build.gradle (make sure mavenCentral() is among your repos)
dependencies {
implementation "com.graphql-java:graphql-java-spring-boot-starter:1.0"
}
or to your pom.xml
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-spring-boot-starter</artifactId>
<version>1.0</version>
</dependency>
We also provide a artifact for non Boot Application.