Beginner’s Guide to GraphQL with Spring Boot

Swathi Prasad
ITNEXT
Published in
5 min readAug 21, 2019

--

GraphQL is a query language for APIs that allows clients to request limited data they need, making it possible for clients to gather data in a limited number of requests. GraphQL is strongly typed protocol and all data operations are validated against a GraphQL schema.

In this article, we will build a simple GraphQL server with Spring Boot.

Adding Maven Dependencies

Create a sample Spring Boot application and add the following dependencies.

  1. graphql-spring-boot-starter is used for enabling GraphQL servlet and it becomes available at a path /graphql. It initializes GraphQLSchema bean.
  2. graphql-java allows to write schema with GraphQL schema language which is simple to understand.
  3. graphiql-spring-boot-starter provides user interface using which we could test our GraphQL queries and view query definition.
        <dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-spring-boot-starter</artifactId>
<version>5.0.2</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-tools</artifactId>
<version>5.2.4</version>
</dependency>
<dependency>

--

--

Software architect and developer living in Germany. Sharing my opinion and what I learn.