A simple reference example Kotlin GraphQL service

Overview

BookOrganizer

A simple reference example Kotlin GraphQL service, written for colleagues coming over from Python & FastAPI/Flask + Ariadne/Graphene.

  • Async GraphQL built on Netflix DGS and Spring.
  • Annotation based queries (crud) and dynamically generated execution spec based queries (custom) for comparison.
  • Simple example mutation.
  • A few example tests with and without mocking.
  • Gradle test configuration with property based filtering and custom test logging.

Notes

In practice, you'll be using the approach outlined under crud far more often. I've included a more dynamic version under custom, using simple logic to construct a query from variable inputs. (Primarily to provide a simple example for reference that is written in Kotlin and is async).

There are multiple ways to handle mutations via Netflix DGS, this is just one simple example.

Gradle is a powerful tool. In the build.gradle.kts file, you'll find one way of many to separate tests, and an optional approach in Gradle's Kotlin DSL to custom output. (In this case, showing the number of tests that passed, failed, and were skipped).

I'm using Postgresql locally via Docker - this will need to be running in order to successfully run the example app, and to run any integration tests.

This is based off a personal project to help someone search their library of 2000+ books.

Guide

Database

Local Postgresql instance via Docker:

The sh files in database/ use the local environment variables:

  • DEV_PG_USER
  • DEV_PG_PASSWORD
  • DEV_PG_PORT

and the postgres database (default).

# Initial setup:
./setup.sh
# Run container
./run.sh
# Stop
./stop.sh

Run

gradle bootRun

URLs

GraphiQL playground: http://localhost:8080/graphiql/index.html

GraphQL endpoint: http://localhost:8080/graphql/

Testing

Run non integration tests only (default):

gradle test

Run integration tests only:

gradle test -Pintegration

Run all tests:

gradle test -Pall

To see more info, including standard output, pass in -i or --info.

More info

Spring helpfully includes a HELP.md in new projects created via Start.Spring

You might also like...
GraphQL for Java with Spring Boot made easy.

GraphQL for Java with Spring Boot made easy.

This repository demonstrates Spring GraphQL + RSocket + WebFlux + R2DBC + H2

Reactive GraphQL with Spring This repository demonstrates Spring GraphQL + RSocket + WebFlux + R2DBC + H2 O__ +-----------+

PeopleInSpace GraphQL Server

PeopleInSpace GraphQL Server GraphQL backend allowing querying list of people in

Template to accelerate the creation of new apps using Spring Boot 3, MongoDB & GraphQL.

Template to accelerate the creation of new apps using Spring Boot 3, MongoDB & GraphQL.

Koltin Multplatform Project that interacts with a GraphQL server to display golf scores, player and weather information.
Koltin Multplatform Project that interacts with a GraphQL server to display golf scores, player and weather information.

GolfScoresKMM Koltin Multplatform Project that interacts with a GraphQL server to display golf scores, player and weather information. The app is setu

Mock up social media android application created to interact with a backend Java server using GraphQL.

The Community Board Project Authorship: author: dnglokpor date: may 2022 Project Summary: The Community Board Project consists of a Java Spring Boot b

Starter project to create a simple RESTful web service in Kotlin

Modified: Adding Koin for DI Using JWT for authentication and authorization Dropping proprietary FlyAway tool Single Page Application support Starter

Account-hexa-service-kotlin - Microservice with Kotlin using Hexagonal architecture

Microservice Construindo microservice de conta para fins Didáticos. Objetivos Cr

Demo Spting REST Service on Kotlin. Works with PostgreSQL via Spring Data. Data initialization provided by liquibase

Spring Boot REST API with Kotlin Spring Boot REST API service. Spring Data with PostgreSQL. Data initialization with Liquibase. Swagger UI Reference D

Owner
Dan Pozmanter
Dan Pozmanter
Kotlin-GraphQL-Apollo - Sencillo cliente para consumir una API GraphQL con Apollo usando Kotlin

Kotlin GraphQL Apollo Sencillo cliente para consumir una API GraphQL con Apollo

José Luis González Sánchez 2 Jan 25, 2022
GraphQL Jetpack - A collection of packages for easily writing Java GraphQL server implementations

GraphQL Jetpack A collection of packages for easily writing Java GraphQL server

Ryan Yang 18 Dec 2, 2022
Victor Hugo 1 Feb 2, 2022
OO Boot Camp reference implementation for Jordanian client in Kotlin in January 2022

oo_boot_camp_2022-01-24_kotlin Copyright (c) 2022 by Fred George May be used fre

Fred George 0 Mar 6, 2022
Team management service is a production ready and fully tested service that can be used as a template for a microservices development.

team-mgmt-service Description Team management service is a production ready and fully tested service that can be used as a template for a microservice

Albert Llousas Ortiz 18 Oct 10, 2022
Accessibility-Service - Filter url from browser by using accessibility service

Accessibility Service example Filter url from browser by using accessibility ser

AmirMohammad Yazdanmanesh 8 Nov 29, 2022
A sample skeleton backend app built using Spring Boot kotlin, Expedia Kotlin Graphql, Reactive Web that can be deployed to Google App Engine Flexible environmennt

spring-kotlin-gql-gae This is a sample skeleton of a backend app that was built using: Spring Boot(Kotlin) Reactive Web Sprinng Data R2DBC with MYSQL

Dario Mungoi 7 Sep 17, 2022
Kotlin backend based on the Clean Architecture principles. Ktor, JWT, Exposed, Flyway, KGraphQL/GraphQL generated endpoints, Gradle.

Kotlin Clean Architecture Backend Kotlin backend based on the Clean Architecture principles. The application is separated into three modules: Domain,

null 255 Jan 3, 2023
🗼 yukata (浴衣) is a modernized and fast GraphQL implementation made in Kotlin

?? yukata 浴衣 - Modernized and fast implementation of GraphQL made in Kotlin yukata is never meant to be captialised, so it'll just be yukata if you me

Noel 5 Nov 4, 2022
An application that simulate the Swedish Transport Agency, implemented with Spring Boot, Kotlin and GraphQL

graphql-kotlin-spring-server An application that simulate the Swedish Transport Agency, implemented with Spring Boot, Kotlin and GraphQL Running the s

null 0 Oct 31, 2021