Skip to content

fvilla/blog-graphql-spring-service

 
 

Repository files navigation

Build Status Maintainability Test Coverage

GraphQL Spring Boot Blog

Introduction

This repo contains a simple Spring Boot (2.x) service that implements GraphQL API. The implementation is based on graphql-java-tools a GraphQL java library inspired by Apollo.

graphql-and-spring

Application

The application implements GraphQL on top of JPA repositories. The application provides basic functionality to store Person and Notes.

model

The graphQL API contains queries, mutations and subscriptions. For more details have a look at the schema

Run with docker

Pull and run the image.

docker run -d --name grapql-demo -p 8088:8080 npalm/graphql-java-demo

The following endpoints are now available:

Example usages

Once the application is running point a browser to http://localhost:8080/graphiql. Which will open the GraphQL IDE. Here you can simple enter GraphQL queries. Since GraphQL is based on a schema you have completion features and documentation directly available in the browser.

The response should like as follow.

"Your subscription data will appear here after server publication!"

Finally make a comment via a mutation in a new browser window. Find a talkId in the result of the first query.

Have now a look on the subscription window, here the update should be visible.

Build and Run

Be aware that the React app is not part of this repo but linked as a GIT submodule. Either clone the repo with --recurse-submodules or after checkout run git submodule update --init --recursive to update the module.

Gradle

To build the Java application just run:

./gradlew build

To run the application run.

./gradlew bootRun

To run the React app:

cd react-web
yarn && yarn start

Docker

The Docker file build both the Java and React app to a single Jar and package the in a docker image.

Build image

docker build -t grahpql-demo .

Run the container

docker run -it --rm -p 8080:8080 graphql-demo

Now the container should be running and you can play around with GraphQL.

About

A GraphQL enabled Sprig Boot Services

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 98.2%
  • Dockerfile 1.8%