SlideShare a Scribd company logo
João Esperancinha
Apollo 4 Kotlin
Made me GraphQL
2024/11/12
Gnothi seauton
Know thyself
What components make up this
talk?
What is GraphQL?
● Query Language
● Developed by Facebook
2015
● Runtime Engine
● Exact data requests
● It is not REST
● One single endpoint
● Overfetching and
underfetching of data
What does
GraphQL
solves?
● Multiple endpoints in general
but particularly for the same
resource
● Requirement Changes
● Lack of typed contracts
● Inconsistent and redundant
API Documentation
What is Apollo Kotlin?
● Complex Queries
● Efficient Data
Fetching
● Client Flexibility
● Evolving APIs
● Spring GraphQL Integration
What does
Apollo Kotlin
solve?
● Code generation
● Type-Safe Queries and
Responses
● Optimized Caching and Offline
Support
● Coroutines and Asynchronous
Operations
● Flexible Networking
Integration
● Error Handling
● Server-Side Usage
● Integration with Other Apollo
Tools
● Efficient communication with
GraphQL APIs
What is Spring GraphQL?
● Efficient Data Fetching with Batch
Loading
● Unified API endpoint
● Data Fetching Flexibility
● GraphQL Annotations
● Schema driven development
● GraphiQL and Testing
● Security and Access Control
What does
Spring
GraphQL
solve?
● Overfetching and
underfetching of data
● Consolidates all APIs into a
single endpoint
● Improving Data Fetching
Efficiency
● Enforcing a Clear Schema for
API Interactions
● Reducing Redundant API Calls
What does
Spring
GraphQL
solve?
● Real-Time Data with
Subscriptions
● Enhanced Error Management
and Validation
● Fine-Grained Access Control
● Developer Productivity with
Tooling
● Smooth Integration with the
Spring Ecosystem
Kairos
Know the right moment
How does the system look like?
Apollo 4 Kotlin made me Graphql and I learned how to use it
Meden agan
Nothing in excess
How to program it?
Setting up the guitar-service
● spring-boot-starter-webflux - Make it reactive
● spring-boot-starter-graphql - Enable GraphQL
● kotlin-stdlib - Enable Kotlin
● kotlin-reflect - To enable necessary reflection
features
● spring-data-commons - Required for the data
structures
● kotlinx-coroutines-core - Required coroutine
libraries
● kotlinx-coroutines-reactor - Reactive services
engine
Creating the guitar service
type Query {
guitarById(id: ID): GuitarDto
ownerById(id: ID): OwnerDto
}
type GuitarDto {
id: ID
brand: String
model: String
year: Int
owner: OwnerDto
}
type OwnerDto {
id: ID
firstName: String
lastName: String
}
schema.graphqls - By
default, this file is kept in
the resources folder. Spring
GraphQL knows to find it
there
Creating the guitar-service
spring.graphql.graphiql.enabled=true
spring.main.web-application-
type=reactive
application.properties
@Controller
class OwnerController(
val ownerService: OwnerService
) {
@QueryMapping
suspend fun ownerById(@Argument("id") id: Long): OwnerDto?
= ownerService.getByIdOrNull(id)
}
@Controller
@QueryMapping
@Argument
GraphQL still follows the
MVC
pattern
QueryMapping maps the
method to the definition
Argument maps the input
argument of the method
Creating the guitar-service
spring.graphql.graphiql.enabled=true
spring.main.web-application-
type=reactive
@Controller
class GuitarController(
val guitarService: GuitarService,
val ownerService: OwnerService
) {
@QueryMapping
suspend fun guitarById(@Argument("id") id: Long) =
guitarService.getByIdOrNull(id)
@SchemaMapping
suspend fun owner(guitarDto: GuitarDto): OwnerDto? =
ownerService.getByIdOrNull(guitarDto.ownerId)
}
@SchemaMapping
application.properties
SchemaMapping maps
parts of the parent object
with its child objects
GraphiQL - Interface
http://localhost:8080/graphiql?path=/
graphql
Setting up the guitar-client
● In Gradle
● apollo-runtime - Enable runtime to create object
● com.apollographql.apollo - Configure apollo plugin
apollo {
service("service") {
packageName.set("org.jesperancinha.guitar.gui")
introspection {
endpointUrl.set("http://localhost:8080/graphql")
schemaFile.set(file("src/main/graphql/schema.graphqls"))
}
}
}
Setting up the guitar-client in Gradle
packageName is the
package name of the
created classes
endpointUrl is the address where
we can find our graphql definition
schemaFile is where we want the
fetched definition to be saved to
schemaFile
packageName
endpointUrl
DEMO Time!
Questions?
I am an inquisitive
cat
Resources
● https://spring.io/guides/gs/graphql-server
● https://www.apollographql.com/docs/kotlin/tutorial/04-execute-the-
query
● https://plugins.jetbrains.com/plugin/8097-graphql
Source code
https://github.com/jesperancinha/guitar-
shop
About me
● Homepage - https://joaofilipesabinoesperancinha.nl
● Threads - https://www.threads.net/@joaofisaes
● LinkedIn - https://www.linkedin.com/in/joaoesperancinha/
● YouTube - https://www.youtube.com/@jesprotech
● Bluesky - https://bsky.app/profile/jesperancinha.bsky.social
● Mastodon - https://masto.ai/@jesperancinha
● GitHub - https://github.com/jesperancinha
● Hackernoon - https://hackernoon.com/u/jesperancinha
● DevTO - https://dev.to/jofisaes
● Medium - https://medium.com/@jofisaes
Thank you!
See you next time!

More Related Content

PPTX
Kotlin REST & GraphQL API
PDF
Getting Started with Spring for GraphQL
PDF
API Management for GraphQL
PPTX
An intro to GraphQL
PDF
Tutorial: Building a GraphQL API in PHP
PDF
GraphQL + relay
PDF
Modern APIs with GraphQL
PDF
GraphQL in an Age of REST
Kotlin REST & GraphQL API
Getting Started with Spring for GraphQL
API Management for GraphQL
An intro to GraphQL
Tutorial: Building a GraphQL API in PHP
GraphQL + relay
Modern APIs with GraphQL
GraphQL in an Age of REST

Similar to Apollo 4 Kotlin made me Graphql and I learned how to use it (20)

PPTX
GraphQL API Crafts presentation
PDF
Graphql usage
PDF
Exposing GraphQLs as Managed APIs
PDF
Modular GraphQL with Schema Stitching
PPTX
Redux vs GraphQL
PDF
The GraphQL Ecosystem in 2018
PPTX
Harnessing the Power of GraphQL in WordPress
PDF
Marco Liberati - Graph analytics
PDF
GraphQL ♥︎ GraphDB
PPTX
Introduction to GraphQL
PDF
GraphQL with .NET Core Microservices.pdf
PPTX
Shift Remote: WEB - GraphQL and React – Quick Start - Dubravko Bogovic (Infobip)
PPTX
GraphQl Introduction
PDF
Graphql Overview By Chirag Dodia
PPTX
CONDG April 23 2020 - Baskar Rao - GraphQL
PDF
Building Fullstack Serverless GraphQL APIs In The Cloud
PDF
Boost your APIs with GraphQL
PDF
Collaborative environment with data science notebook
PPTX
Revealing ALLSTOCKER
PPTX
Presentation on angular 5
GraphQL API Crafts presentation
Graphql usage
Exposing GraphQLs as Managed APIs
Modular GraphQL with Schema Stitching
Redux vs GraphQL
The GraphQL Ecosystem in 2018
Harnessing the Power of GraphQL in WordPress
Marco Liberati - Graph analytics
GraphQL ♥︎ GraphDB
Introduction to GraphQL
GraphQL with .NET Core Microservices.pdf
Shift Remote: WEB - GraphQL and React – Quick Start - Dubravko Bogovic (Infobip)
GraphQl Introduction
Graphql Overview By Chirag Dodia
CONDG April 23 2020 - Baskar Rao - GraphQL
Building Fullstack Serverless GraphQL APIs In The Cloud
Boost your APIs with GraphQL
Collaborative environment with data science notebook
Revealing ALLSTOCKER
Presentation on angular 5
Ad

More from João Esperancinha (17)

PDF
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
PPTX
Decoding Kotlin - Your guide to solving the mysterious in Kotlin - JNation2025
PPTX
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
PPTX
Boosting performance and functional style with Project Arrow from a practical...
PPTX
Start from the Package in Spring CDS - Basic course
PPTX
Monads are no Nomads - Unlocking the basics
PPTX
C.R.a.C in Spring - I froze my server! (15 minute session for NLJUG speaker a...
PPTX
Could Virtual Threads cast away the usage of Kotlin Coroutines
PPTX
Managing gRPC Services using Kong KONNECT and the KONG API Gateway
PPTX
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
PPTX
Kuma Meshes Part I - The basics - A tutorial
PPTX
Fields in Java and Kotlin and what to expect.pptx
PPTX
Demystifying Co, Contra, In Kotlin modifier keywords.pptx
PPTX
Unlocking the Power of Kotlin Channels.pptx
PPTX
Exploring Tailrec Through Time Until Kotlin.pptx
PPTX
Reactive programming with Spring Webflux.pptx
PPTX
KONNECT Kong-Presentation How to protect web applications
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
Decoding Kotlin - Your guide to solving the mysterious in Kotlin - JNation2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Boosting performance and functional style with Project Arrow from a practical...
Start from the Package in Spring CDS - Basic course
Monads are no Nomads - Unlocking the basics
C.R.a.C in Spring - I froze my server! (15 minute session for NLJUG speaker a...
Could Virtual Threads cast away the usage of Kotlin Coroutines
Managing gRPC Services using Kong KONNECT and the KONG API Gateway
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Kuma Meshes Part I - The basics - A tutorial
Fields in Java and Kotlin and what to expect.pptx
Demystifying Co, Contra, In Kotlin modifier keywords.pptx
Unlocking the Power of Kotlin Channels.pptx
Exploring Tailrec Through Time Until Kotlin.pptx
Reactive programming with Spring Webflux.pptx
KONNECT Kong-Presentation How to protect web applications
Ad

Recently uploaded (20)

PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Digital Strategies for Manufacturing Companies
PDF
AI in Product Development-omnex systems
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Introduction to Artificial Intelligence
PDF
System and Network Administraation Chapter 3
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
medical staffing services at VALiNTRY
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Transform Your Business with a Software ERP System
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Essential Infomation Tech presentation.pptx
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Digital Strategies for Manufacturing Companies
AI in Product Development-omnex systems
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Introduction to Artificial Intelligence
System and Network Administraation Chapter 3
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Reimagine Home Health with the Power of Agentic AI​
medical staffing services at VALiNTRY
Upgrade and Innovation Strategies for SAP ERP Customers
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Transform Your Business with a Software ERP System
Which alternative to Crystal Reports is best for small or large businesses.pdf
Navsoft: AI-Powered Business Solutions & Custom Software Development
Operating system designcfffgfgggggggvggggggggg
Essential Infomation Tech presentation.pptx
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free

Apollo 4 Kotlin made me Graphql and I learned how to use it