Skip to content
amberpan edited this page May 3, 2020 · 5 revisions

GraphQL with Spring Boot


Introduction

Traditional REST APIs are difficult to maintain when you have frequently changing requirements. Web APIs may end up serving too much or too less data.

Another limitation with REST API is, if client needs to fetch multiple resources, it has to make multiple calls OR server has to introduce new API which combines multiple resources and sends to client which client may not always require.

GraphQL provides the flexibility to client to choose what it needs. It also provides the ability to fetch multiple resources in a single API call.


Pre-requisites

  • JDK
  • IDE(IntelliJ/Eclipse/Any)

Project setup instructions

  • Use spring initializr to quickly setup sample project with all necessary dependencies(https://start.spring.io/).

  • For GraphQL, add below dependency:

Maven:

<dependency>
    <groupId>com.graphql-java</groupId>
    <artifactId>graphql-spring-boot-starter</artifactId>
    <version>7.0.1</version>
</dependency>

Gradle

implementation 'com.graphql-java-kickstart:graphql-spring-boot-starter:7.0.1'

Clone this wiki locally