Schema-first GraphQL server framework for Java
APACHE-2.0 License
= Grapid {nbsp}image:{maven-image}[Maven Central,link="{maven-link}"] :maven-image: https://maven-badges.herokuapp.com/maven-central/com.github.pukkaone/grapid-core/badge.svg :maven-link: https://maven-badges.herokuapp.com/maven-central/com.github.pukkaone/grapid-core
Grapid is an opinionated, schema-first framework for implementing GraphQL servers in Java. While the framework prescribes where you put GraphQL schema definition files and Java classes, you only need to implement the business logic for your API. The framework generates the code to wire GraphQL requests to your business logic.
== GraphQL Server Quick Start Guide
Add this Spring Boot starter which auto-configures a GraphQL server accepting requests by HTTP.
By default, the server URL path is /graphql
relative to the context path.
Add this Maven plugin which compiles GraphQL schema definition files to Java source files.
An API version represents a set of types and operations defined by a GraphQL schema. A version identifier must be a valid Java identifier and not a Java keyword.
By convention, GraphQL schema definition files are located under a resources directory
src/main/resources/graphql/_version_/
where version identifies an API version. Create the
resources directory src/main/resources/graphql/v2018_12_31/
. Add this GraphQL schema definition
file in the directory. By convention, GraphQL schema definition file names end with the extension
.graphqls
.
type Author { id: ID! name: String! }
The GraphQL schema defines the root object type Query. The compiler appends the suffix Resolver
to this root object type name to derive the Java class name QueryResolver. As an application
developer, you must implement the QueryResolver class. By convention, this class is in the Java
package named packagePrefix.resolver
.
package com.example.graphql.resolver;
import com.example.graphql.v2018_12_31.type.Author; // <1> import org.springframework.stereotype.Component;
@Component public class QueryResolver {
<1> The compiler generated the simple Java data class Author from the GraphQL object type Author.
<2> The compiler translated this Java method signature from the field author
of the GraphQL
root object type Query.
Run the application. In https://github.com/prisma/graphql-playground[GraphQL Playground],
connect to http://localhost:8080/graphql/v2018_12_31
to send a GraphQL query to the server.
For more details, see the https://pukkaone.github.io/grapid/documentation/[Getting Started Guide].
== Interface Stability
Major version zero (0.x.x) is for initial development. Anything may change at any time. The public API should not be considered stable.
== Building
Prerequisites are:
To compile the project and run integration tests: