This is a Spring Boot based GraphQL sample application written in Kotlin.
You can use this example to easily setup your own GraphQL application.
This project consists of two (maven) modules:
-
stubs: containing Spring Cloud Contract files for generation of WireMock stubs
-
application: GraphQL example application written in Kotlin using GraphQL Java Tools and the
com.graphql-java-kickstart
and the provided Spring Boot started modules:graphql-spring-boot-starter
.
-
Create project a Spring Boot project using Spring Initializer
-
Add graphql-spring-boot-starters
Example query:
query {
orderById(id: "1") {
totalPrice
items {
status
productId
}
}
}
Example slow query:
query {
orderById(id: "1") {
totalPrice
items {
status
productId
product {
title
}
}
}
}
Example mutation query:
mutation {
cancelOrderItem(orderItemCancellation: {orderId: "1", orderItemId: "1", reason: "I dont want it!"} ) {
id
status
}
}