Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pukkaone/grapid
Schema-first GraphQL server framework for Java
https://github.com/pukkaone/grapid
framework graphql graphql-java graphql-server java spring spring-boot
Last synced: about 1 month ago
JSON representation
Schema-first GraphQL server framework for Java
- Host: GitHub
- URL: https://github.com/pukkaone/grapid
- Owner: pukkaone
- License: apache-2.0
- Created: 2019-02-22T06:35:45.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-12-25T02:17:52.000Z (11 months ago)
- Last Synced: 2024-09-30T10:43:00.766Z (about 2 months ago)
- Topics: framework, graphql, graphql-java, graphql-server, java, spring, spring-boot
- Language: Java
- Homepage: https://pukkaone.github.io/grapid/
- Size: 606 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE.txt
Awesome Lists containing this project
README
= 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-coreGrapid 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.[source,xml]
----com.github.pukkaone
grapid-web-spring-boot-starter
${grapid.version}----
Add this Maven plugin which compiles GraphQL schema definition files to Java source files.
[source,xml]
----com.github.pukkaone
grapid-maven-plugin
${grapid.version}
com.example.graphql
compile
----
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`..Author.graphqls
[source,graphql]
----
type Author {
id: ID!
name: String!
}type Query {
author(id: ID!): Author
}
----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``..QueryResolver.java
[source,java]
----
package com.example.graphql.resolver;import com.example.graphql.v2018_12_31.type.Author; // <1>
import org.springframework.stereotype.Component;@Component
public class QueryResolver {public Author author(String id) { // <2>
return Author.builder()
.id(id)
.name("NAME")
.build();
}
}
----
<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:
- Java 17
- GradleTo compile the project and run integration tests:
----
gradle publishToMavenLocal check
----