Skip to content

Latest commit

 

History

History
61 lines (46 loc) · 1.14 KB

File metadata and controls

61 lines (46 loc) · 1.14 KB

GraphQL + Spring Boot example application

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.

Getting started with GraphQL and Spring Boot

  • Create project a Spring Boot project using Spring Initializer

  • Add graphql-spring-boot-starters

Queries and mutations

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
  }
}