my-spring-boot-experiments
  • README
  • Spring Batch implementation
  • API Example for Archunit
  • spring-boot-chaos-monkey
  • Grafana LGTM Implementation
  • MongoDb for insertion and search using elastic search
  • OpenSearch Implementation
  • spring-boot-rabbitmq-thymeleaf
  • boot-rest-docs-sample
  • boot-strategy-plugin
  • spring-boot-togglz-sample
  • spring-boot-ultimate-redis
  • GraphQL
    • spring-boot-graphql-querydsl
    • GraphQl implementation using webflux
    • GraphQl implementation using webmvc
  • httpClients
    • http-proxy
    • rest-template
    • rest-client
    • web-client-mvc
    • web-client-webflux
  • jmh-benchmark
  • jpa
    • Custom Sequence
    • Hibernate Envers Implementation
    • multiple datasources using Spring Boot
    • spring-boot-hibernate2ndlevelcache-sample
    • JNDI in embedded Tomcat
    • JPA Jooq Marriage
    • JPA locks implementation
    • read-replica-with-spring-boot
    • KeySet Pagination Using Blaze
    • KeySet Pagination Using Data-JPA
    • MultiTenancy using Hibernate in Spring Data JPA
      • multitenancy-db
      • multidatasource-multitenancy
      • Partitioned (Discriminator) Data – the data for each tenant is partitioned by a discriminator value
      • schema
  • open-api-spring-boot
  • r2dbc
    • r2dbc-jooq
    • PostgreSQL JSON and enum column support
    • PostgreSQL Notify and Listen support using reactive spring boot
    • r2dbc-boot
    • reactive-cache
  • scheduler
    • Scheduling using JobRunr
    • Scheduling using Quartz
    • Scheduling using Shedlock distribution
  • Code Of Conduct
Powered by GitBook
On this page
  • Key Points
  • Format code
  • Run tests
  • Run locally
  • Using Testcontainers at Development Time
  • Useful Links
  • About Graph QL
  • How to fetch data using URL

Was this helpful?

Edit on GitHub
  1. GraphQL

GraphQl implementation using webflux

Previousspring-boot-graphql-querydslNextGraphQl implementation using webmvc

Last updated 4 months ago

Was this helpful?

Implements a reactive GraphQL server using Spring WebFlux, enabling highly scalable endpoint queries.

Key Points

  • Reactive Execution: Non-blocking data fetchers.

  • Scalable: Ideal for high-concurrency scenarios.

  • Performance: Handles thousands of concurrent requests with minimal overhead.

  • Memory Efficient: Reduces memory footprint through backpressure handling.


The spring-boot-starter-graphql is a starter dependency for Spring Boot applications that allows them to integrate with GraphQL APIs. It provides a set of tools and libraries that enable developers to easily build GraphQL-based applications and expose them through a GraphQL endpoint. The starter includes support for GraphQL queries, mutations, subscriptions, and schema definitions, as well as integration with Spring Boot's autoconfiguration and dependency injection features.

Format code

./mvnw spotless:apply

Run tests

./mvnw clean verify

Run locally

docker-compose -f docker/docker-compose.yml up -d
./mvnw spring-boot:run -Dspring-boot.run.profiles=local

Using Testcontainers at Development Time

You can run TestApplication.java from your IDE directly. You can also run the application using Maven as follows:

./mvnw spring-boot:test-run

Useful Links

  • Swagger UI: http://localhost:8080/swagger-ui.html

  • Actuator Endpoint: http://localhost:8080/actuator

  • GraphIQL: http://localhost:8080/graphiql

About Graph QL

GraphQL provides three main concepts:

  1. Queries: Read data from the server

  2. Mutations: Update data on the server

  3. Subscriptions: Read data over a period of time (e.g., stock market updates, inflight recorder)

How to fetch data using URL

  • There are two types of annotations that can be used expose API

    • @SchemaMapping(typeName = "Query", field = "customers") , Here typeName should be matching the schema declared in schema.graphqls and filed should match the definition

    • @QueryMapping , Short hand for @SchemaMapping where field if not specified will be obtained from methodname and it should be declared in schema.graphqls

Sample data

 {
    customers {
    id
    name
    orders {
        id
     }
   }
  }

or

{
    customers {
     id
    }
}

Fetching data based on name

{
    customersByName(name: "kolli") {
        id
        name
    }
}
Watch the implementation video