SlideShare a Scribd company logo
1 of 32
Kotlin Backend
Rest & GraphQL
About Me
● Blog
○ https://animus.design
● GitLab
○ https://gitlab.com/AnimusDesign
● Job: Tech Lead @ Equinox
● Personal Projects
○ Music Recommendation System
○ Kotlin Examples
○ New Web Framework in Kotlin
○ Content Creation Service
Over ten years of experience. With a focus on
functional reactive full stack development. Utilizing
Kotlin to ease delivering of the domain to the client.
Early adopter of multi-platform to share code across
multiple targets.
What is GraphQL
● GraphQL is a newish API format developed by FaceBook for React. First released in 2015
○ Primarily used by Javascript Frameworks
● It is strongly typed, with a schema. Allowing for autocompletion, and is self documenting.
● You specify what data you wish to receive. In that vein you can chain multiple queries, without hitting
multiple endpoints.
○ Think of it as akin to sql, with functions instead of a language, but you still specify the returns.
● Advanced
○ Can whitelist queries run in production, limiting ad hoc queries.
○ Can build fragments that act as building blocks inside queries.
● Hacker News Discussion on Switching to GraphQL
Simple Query
Complex Query
GraphQL Additions
● GraphQL is a specification, additional libraries/frameworks expand its capabilities.
○ Much like an api gateway for REST, joining microservices.
● This is required because the structure of the data is put on the client instead of the server.
● Relay & Relay Modern from FaceBook, allow data binding to components, caching, etc.
● Apollo acts as a GraphQL API GateWay, with monitoring, alerting, and other features.
○ Client supports caching, binding, and managing local state of the application.
● Important
○ Support outside of JavaScript is weak. As an example JVM doesn’t support caching in Apollo, but
supports performance tracing.
● I will be focusing on Apollo
GraphQL Schema Stitching
● Schema stitching combines several GraphQL end points into one.
● Equivalent to an api gateway.
● When making a query, it will route the request to the proper service.
Why is the Framework Important?
● Isomorphic rendering, or server side rendering with GraphQL
● Caching, to limit hitting the primary data source repeatedly.
● How the javascript/Client interacts with the data layer.
● Whether the build process verifies the requested fields are in the schema.
● Performance monitoring, and trace monitoring.
● Schema stitching, or combining multiple graphql services together.
In short your framework choice will largely dictate your backend
language.
Why use GraphQL
● You’re using a javascript web/mobile framework.
● With Apollo client for web and mobile.
● Limits the data requested.
● Can whitelist queries, verifying what is queried in production.
● Less data requested, means less transfer.
○ Customize the data you retrieve from the data source.
● Reduce number of api calls.
● Strongly typed response.
● No need to maintain / generate swagger documentation.
Why Apollo?
● Polyglot support Swift (iOS), Kotlin (Android), JavaScript (vue, react, angular)
clients.
● Wide range of backend server support
○ With varying levels of support..
■ Tracing is supported in Java and other languages, see here for latest
supported languages.
○ Caching javascript only at this time.
● Integration with pager-duty and data dog, easing monitoring.
● Shiny dashboard with pretty lines.
● Better community integration, things like React router for isomorphic
rendering.
● Professional support
Backend MakeUp
● API
○ Jooby
■ HTTP Routing Library
○ Java-GraphQL
■ FrameWork for GraphQL
○ Graphql-spqr
■ Java 8+ Bindings easing definition, but not targeted towards
kotlin.
○ Jooq
■ Database layer that acts as a thin layer for operations.
○ Hikari CP
■ Connection pooling for the database.
● Apollo
○ GraphQL GateWay Server
○ Performance Monitoring
● Graphite + Grafana Monitoring
Project Structure
● Base Structure we will be working with.
● api
○ Is the backend GraphQL and Rest layer.
● database
○ The database interaction library.
● Web
○ A react frontend
● Anything gradle is build related.
DataBase
● Auto generated java classes via jooq.
● No hand writing or mapping to database.
● Generated via a gradle build file.
● Utilizes environment variables to integrate
with your pipeline.
● Looks strikingly like SQL.
Data Model
● Name Basic - Provides information on actors, writers, crews, etc.
● Title Basic - Common information on a title can be a movie or tv episode.
● Title AKA - Title also known as a table of other title names, not used.
● Title Episode - Maps a parent title (TV Show), to seasons, episode numbers, and episode
ids.
● Title Crew - Takes a title id and provides a list of directors and writers.
Pulled from IMBD sample data set. Small sample set of movies, tv shows, writers, directors, and
actors.
https://www.imdb.com/interfaces/
Jooby: HTTP API GraphQl & Rest
● GraphQL requires a single POST or GET endpoint
● Supports multi versioned REST endpoints
● Swagger and RAML generation for Rest
● Metrics, supporting graphite, data dog and more.
● Docker support
● A number of other modules
● Running on Netty an asynchronous event server
○ Can run on other servers.
● Support for hot reloading, i.e. automatic recompilation.
There are a Plethora of HTTP Services
Choose what works for you!
● Vertx
● DropWizard
● Javalin
● Spark
● Ktor
● I’m sure I’m forgetting something.
Jooby Making End Points
● Closures, lambda functions included in a type safe DSL builder.
● Supports MVC class based method (My preference)
Jooby Closure REST EndPoint
● A type safe builder for your end points in the run section for Jooby.
● Supports arguments and parameters.
● Each http verb is a seperate function
Class MVC Rest EndPoint
- Each Class is a
path
- Annotated with
the HTTP verb
- Can annotate
with sub path
- Automatic
conversion to
json
Single GraphQL EndPoint
- Data classes for response and post
body.
- Read the post body.
- Submit to the schema executor
- Return response.
GraphQL Java
● Strong Community, very active development.
● Support for Apollo (minus caching) and Relay, plus more.
● A number of additions to ease development.
○ https://github.com/graphql-java/awesome-graphql-java
● Can design schema first or classes first.
● Automatic integration with spring.
Limitations of GraphQL Java
● Kotlin is not a first class citizen.
● Builders, that feel a bit heavy in comparison to Kotlin Syntax.
● Documentation is a bit scarce.
● Wiring type definitions, to query resolvers is verbose.
● Doesn’t feel like idiomatic Kotlin
○ There is one Wrapper in Kotlin, but it is not overly active
● Enter GraphQL SPQR.
○ An annotation library that makes adding types and queries very simple.
○ The downside is it doesn’t support Kotlin Data Classes
■ Need to fall back to java in some instances.
■ May encounter esoteric bugs with annotations in Kotlin.
GraphQL Object Definition
● Basic Java POJO
● Annotations for the Getters
Or This Works
● Class constructor with
annotations.
● Common class so can be used
across platforms.
● This is the JVM implementation.
GraphQL Service
Generating the Schema
● Instantiate the Pet Service a singleton
● Instantiate the schema, passing any singletons you develop.
Demo Time
● Data store is using sample data from
IMDB
● REST + GraphQL Endpoints
○ Hot Reloading
● Apollo Engine Integration
○ GraphQL Query Tracing
● Grafana showing Jooby metrics
● Docker build
● Maybe a kotlin + react fetching from
the API.
Closing Thoughts
VertX
If you’re looking for a highly concurrent distributed backend layer. Look at VertX.
● Works with an event loop, and worker pools.
○ Passing information through a message bus.
■ Which can be centralized
■ And accessed from a number of languages.
● Can start with just http endpoints and add more later.
● Built in clustering and service discovery.
● First class Kotlin support.
● Polyglot (Java, Kotlin, Groovy, Scala, Javascript, Ruby)
● HTTP end points, as well as custom TCP/UDP services.
● Akin to an actor model.
● Great GraphQL support.
Changing your data store
● Neo4j (graph database has built in graphql
support).
● In built use of GraphQL Java and Apollo
● But you have to change your data store…
● Called the Grand Stack
Could we create new annotations?
Questions ?

More Related Content

What's hot

Introduction to DevOps and the Practical Use Cases at Credit OK
Introduction to DevOps and the Practical Use Cases at Credit OKIntroduction to DevOps and the Practical Use Cases at Credit OK
Introduction to DevOps and the Practical Use Cases at Credit OKKriangkrai Chaonithi
 
Apache Beam @ GCPUG.TW Flink.TW 20161006
Apache Beam @ GCPUG.TW Flink.TW 20161006Apache Beam @ GCPUG.TW Flink.TW 20161006
Apache Beam @ GCPUG.TW Flink.TW 20161006Randy Huang
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQLRodrigo Prates
 
GraphQL Introduction
GraphQL IntroductionGraphQL Introduction
GraphQL IntroductionSerge Huber
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL StackSashko Stubailo
 
GraphQL ♥︎ GraphDB
GraphQL ♥︎ GraphDBGraphQL ♥︎ GraphDB
GraphQL ♥︎ GraphDBGraphRM
 
Adding GraphQL to your existing architecture
Adding GraphQL to your existing architectureAdding GraphQL to your existing architecture
Adding GraphQL to your existing architectureSashko Stubailo
 
Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)
Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)
Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)Ayla Khan
 
REST vs GraphQL
REST vs GraphQLREST vs GraphQL
REST vs GraphQLSquareboat
 
Improving Mobile Payments With Real time Spark
Improving Mobile Payments With Real time SparkImproving Mobile Payments With Real time Spark
Improving Mobile Payments With Real time Sparkdatamantra
 
Introduction to Ruby Native Extensions and Foreign Function Interface
Introduction to Ruby Native Extensions and Foreign Function InterfaceIntroduction to Ruby Native Extensions and Foreign Function Interface
Introduction to Ruby Native Extensions and Foreign Function InterfaceOleksii Sukhovii
 
GraphQL (Graphene-Django)
GraphQL (Graphene-Django)GraphQL (Graphene-Django)
GraphQL (Graphene-Django)Selo Lee
 
GraphQL in an Age of REST
GraphQL in an Age of RESTGraphQL in an Age of REST
GraphQL in an Age of RESTYos Riady
 
Python Streaming Pipelines with Beam on Flink
Python Streaming Pipelines with Beam on FlinkPython Streaming Pipelines with Beam on Flink
Python Streaming Pipelines with Beam on FlinkAljoscha Krettek
 
GraphQL across the stack: How everything fits together
GraphQL across the stack: How everything fits togetherGraphQL across the stack: How everything fits together
GraphQL across the stack: How everything fits togetherSashko Stubailo
 
Balkan - data eng meetup - data fusion
Balkan - data eng meetup - data fusionBalkan - data eng meetup - data fusion
Balkan - data eng meetup - data fusionBalkan Misirli
 
Introduction to Modern DevOps Technologies
Introduction to  Modern DevOps TechnologiesIntroduction to  Modern DevOps Technologies
Introduction to Modern DevOps TechnologiesKriangkrai Chaonithi
 
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/MeteorWhy UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/MeteorJon Wong
 

What's hot (20)

Introduction to DevOps and the Practical Use Cases at Credit OK
Introduction to DevOps and the Practical Use Cases at Credit OKIntroduction to DevOps and the Practical Use Cases at Credit OK
Introduction to DevOps and the Practical Use Cases at Credit OK
 
GraphQL & Relay
GraphQL & RelayGraphQL & Relay
GraphQL & Relay
 
GraphQL + relay
GraphQL + relayGraphQL + relay
GraphQL + relay
 
Apache Beam @ GCPUG.TW Flink.TW 20161006
Apache Beam @ GCPUG.TW Flink.TW 20161006Apache Beam @ GCPUG.TW Flink.TW 20161006
Apache Beam @ GCPUG.TW Flink.TW 20161006
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
GraphQL Introduction
GraphQL IntroductionGraphQL Introduction
GraphQL Introduction
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
 
GraphQL ♥︎ GraphDB
GraphQL ♥︎ GraphDBGraphQL ♥︎ GraphDB
GraphQL ♥︎ GraphDB
 
Adding GraphQL to your existing architecture
Adding GraphQL to your existing architectureAdding GraphQL to your existing architecture
Adding GraphQL to your existing architecture
 
Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)
Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)
Build GraphQL APIs with Graphene (Big Mountain Data & Dev 2019)
 
REST vs GraphQL
REST vs GraphQLREST vs GraphQL
REST vs GraphQL
 
Improving Mobile Payments With Real time Spark
Improving Mobile Payments With Real time SparkImproving Mobile Payments With Real time Spark
Improving Mobile Payments With Real time Spark
 
Introduction to Ruby Native Extensions and Foreign Function Interface
Introduction to Ruby Native Extensions and Foreign Function InterfaceIntroduction to Ruby Native Extensions and Foreign Function Interface
Introduction to Ruby Native Extensions and Foreign Function Interface
 
GraphQL (Graphene-Django)
GraphQL (Graphene-Django)GraphQL (Graphene-Django)
GraphQL (Graphene-Django)
 
GraphQL in an Age of REST
GraphQL in an Age of RESTGraphQL in an Age of REST
GraphQL in an Age of REST
 
Python Streaming Pipelines with Beam on Flink
Python Streaming Pipelines with Beam on FlinkPython Streaming Pipelines with Beam on Flink
Python Streaming Pipelines with Beam on Flink
 
GraphQL across the stack: How everything fits together
GraphQL across the stack: How everything fits togetherGraphQL across the stack: How everything fits together
GraphQL across the stack: How everything fits together
 
Balkan - data eng meetup - data fusion
Balkan - data eng meetup - data fusionBalkan - data eng meetup - data fusion
Balkan - data eng meetup - data fusion
 
Introduction to Modern DevOps Technologies
Introduction to  Modern DevOps TechnologiesIntroduction to  Modern DevOps Technologies
Introduction to Modern DevOps Technologies
 
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/MeteorWhy UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
 

Similar to Kotlin Backend GraphQL & Rest

GraphQL Bangkok meetup 5.0
GraphQL Bangkok meetup 5.0GraphQL Bangkok meetup 5.0
GraphQL Bangkok meetup 5.0Tobias Meixner
 
Getting Started with Spring for GraphQL
Getting Started with Spring for GraphQLGetting Started with Spring for GraphQL
Getting Started with Spring for GraphQLVMware Tanzu
 
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything togetherSashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything togetherReact Conf Brasil
 
Marco Liberati - Graph analytics
Marco Liberati - Graph analyticsMarco Liberati - Graph analytics
Marco Liberati - Graph analyticsCodemotion
 
GraphQL API Crafts presentation
GraphQL API Crafts presentationGraphQL API Crafts presentation
GraphQL API Crafts presentationSudheer J
 
OpenLineage for Stream Processing | Kafka Summit London
OpenLineage for Stream Processing | Kafka Summit LondonOpenLineage for Stream Processing | Kafka Summit London
OpenLineage for Stream Processing | Kafka Summit LondonHostedbyConfluent
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentationVibhor Grover
 
Modular GraphQL with Schema Stitching
Modular GraphQL with Schema StitchingModular GraphQL with Schema Stitching
Modular GraphQL with Schema StitchingSashko Stubailo
 
GraphQL Bangkok Meetup 6.0
GraphQL Bangkok Meetup 6.0GraphQL Bangkok Meetup 6.0
GraphQL Bangkok Meetup 6.0Tobias Meixner
 
Gobblin @ NerdWallet (Nov 2015)
Gobblin @ NerdWallet (Nov 2015)Gobblin @ NerdWallet (Nov 2015)
Gobblin @ NerdWallet (Nov 2015)NerdWalletHQ
 
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...Kaxil Naik
 
GraphQL-ify your APIs - Devoxx UK 2021
 GraphQL-ify your APIs - Devoxx UK 2021 GraphQL-ify your APIs - Devoxx UK 2021
GraphQL-ify your APIs - Devoxx UK 2021Soham Dasgupta
 
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps WayDevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Waysmalltown
 
How to keep maintainability of long life Scala applications
How to keep maintainability of long life Scala applicationsHow to keep maintainability of long life Scala applications
How to keep maintainability of long life Scala applicationstakezoe
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQLKnoldus Inc.
 

Similar to Kotlin Backend GraphQL & Rest (20)

GraphQL Bangkok meetup 5.0
GraphQL Bangkok meetup 5.0GraphQL Bangkok meetup 5.0
GraphQL Bangkok meetup 5.0
 
Next.js with drupal, the good parts
Next.js with drupal, the good partsNext.js with drupal, the good parts
Next.js with drupal, the good parts
 
Getting Started with Spring for GraphQL
Getting Started with Spring for GraphQLGetting Started with Spring for GraphQL
Getting Started with Spring for GraphQL
 
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything togetherSashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
Sashko Stubailo - The GraphQL and Apollo Stack: connecting everything together
 
Marco Liberati - Graph analytics
Marco Liberati - Graph analyticsMarco Liberati - Graph analytics
Marco Liberati - Graph analytics
 
GraphQL API Crafts presentation
GraphQL API Crafts presentationGraphQL API Crafts presentation
GraphQL API Crafts presentation
 
OpenLineage for Stream Processing | Kafka Summit London
OpenLineage for Stream Processing | Kafka Summit LondonOpenLineage for Stream Processing | Kafka Summit London
OpenLineage for Stream Processing | Kafka Summit London
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentation
 
Modular GraphQL with Schema Stitching
Modular GraphQL with Schema StitchingModular GraphQL with Schema Stitching
Modular GraphQL with Schema Stitching
 
GraphQL Bangkok Meetup 6.0
GraphQL Bangkok Meetup 6.0GraphQL Bangkok Meetup 6.0
GraphQL Bangkok Meetup 6.0
 
Gobblin @ NerdWallet (Nov 2015)
Gobblin @ NerdWallet (Nov 2015)Gobblin @ NerdWallet (Nov 2015)
Gobblin @ NerdWallet (Nov 2015)
 
Spring GraphQL
Spring GraphQLSpring GraphQL
Spring GraphQL
 
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
 
Netty training
Netty trainingNetty training
Netty training
 
Netty training
Netty trainingNetty training
Netty training
 
GraphQL-ify your APIs - Devoxx UK 2021
 GraphQL-ify your APIs - Devoxx UK 2021 GraphQL-ify your APIs - Devoxx UK 2021
GraphQL-ify your APIs - Devoxx UK 2021
 
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps WayDevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
 
Google Cloud Dataflow
Google Cloud DataflowGoogle Cloud Dataflow
Google Cloud Dataflow
 
How to keep maintainability of long life Scala applications
How to keep maintainability of long life Scala applicationsHow to keep maintainability of long life Scala applications
How to keep maintainability of long life Scala applications
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 

Recently uploaded

Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 

Kotlin Backend GraphQL & Rest

  • 2. About Me ● Blog ○ https://animus.design ● GitLab ○ https://gitlab.com/AnimusDesign ● Job: Tech Lead @ Equinox ● Personal Projects ○ Music Recommendation System ○ Kotlin Examples ○ New Web Framework in Kotlin ○ Content Creation Service Over ten years of experience. With a focus on functional reactive full stack development. Utilizing Kotlin to ease delivering of the domain to the client. Early adopter of multi-platform to share code across multiple targets.
  • 3. What is GraphQL ● GraphQL is a newish API format developed by FaceBook for React. First released in 2015 ○ Primarily used by Javascript Frameworks ● It is strongly typed, with a schema. Allowing for autocompletion, and is self documenting. ● You specify what data you wish to receive. In that vein you can chain multiple queries, without hitting multiple endpoints. ○ Think of it as akin to sql, with functions instead of a language, but you still specify the returns. ● Advanced ○ Can whitelist queries run in production, limiting ad hoc queries. ○ Can build fragments that act as building blocks inside queries. ● Hacker News Discussion on Switching to GraphQL
  • 6. GraphQL Additions ● GraphQL is a specification, additional libraries/frameworks expand its capabilities. ○ Much like an api gateway for REST, joining microservices. ● This is required because the structure of the data is put on the client instead of the server. ● Relay & Relay Modern from FaceBook, allow data binding to components, caching, etc. ● Apollo acts as a GraphQL API GateWay, with monitoring, alerting, and other features. ○ Client supports caching, binding, and managing local state of the application. ● Important ○ Support outside of JavaScript is weak. As an example JVM doesn’t support caching in Apollo, but supports performance tracing. ● I will be focusing on Apollo
  • 7. GraphQL Schema Stitching ● Schema stitching combines several GraphQL end points into one. ● Equivalent to an api gateway. ● When making a query, it will route the request to the proper service.
  • 8. Why is the Framework Important? ● Isomorphic rendering, or server side rendering with GraphQL ● Caching, to limit hitting the primary data source repeatedly. ● How the javascript/Client interacts with the data layer. ● Whether the build process verifies the requested fields are in the schema. ● Performance monitoring, and trace monitoring. ● Schema stitching, or combining multiple graphql services together. In short your framework choice will largely dictate your backend language.
  • 9. Why use GraphQL ● You’re using a javascript web/mobile framework. ● With Apollo client for web and mobile. ● Limits the data requested. ● Can whitelist queries, verifying what is queried in production. ● Less data requested, means less transfer. ○ Customize the data you retrieve from the data source. ● Reduce number of api calls. ● Strongly typed response. ● No need to maintain / generate swagger documentation.
  • 10. Why Apollo? ● Polyglot support Swift (iOS), Kotlin (Android), JavaScript (vue, react, angular) clients. ● Wide range of backend server support ○ With varying levels of support.. ■ Tracing is supported in Java and other languages, see here for latest supported languages. ○ Caching javascript only at this time. ● Integration with pager-duty and data dog, easing monitoring. ● Shiny dashboard with pretty lines. ● Better community integration, things like React router for isomorphic rendering. ● Professional support
  • 11. Backend MakeUp ● API ○ Jooby ■ HTTP Routing Library ○ Java-GraphQL ■ FrameWork for GraphQL ○ Graphql-spqr ■ Java 8+ Bindings easing definition, but not targeted towards kotlin. ○ Jooq ■ Database layer that acts as a thin layer for operations. ○ Hikari CP ■ Connection pooling for the database. ● Apollo ○ GraphQL GateWay Server ○ Performance Monitoring ● Graphite + Grafana Monitoring
  • 12. Project Structure ● Base Structure we will be working with. ● api ○ Is the backend GraphQL and Rest layer. ● database ○ The database interaction library. ● Web ○ A react frontend ● Anything gradle is build related.
  • 13. DataBase ● Auto generated java classes via jooq. ● No hand writing or mapping to database. ● Generated via a gradle build file. ● Utilizes environment variables to integrate with your pipeline. ● Looks strikingly like SQL.
  • 14. Data Model ● Name Basic - Provides information on actors, writers, crews, etc. ● Title Basic - Common information on a title can be a movie or tv episode. ● Title AKA - Title also known as a table of other title names, not used. ● Title Episode - Maps a parent title (TV Show), to seasons, episode numbers, and episode ids. ● Title Crew - Takes a title id and provides a list of directors and writers. Pulled from IMBD sample data set. Small sample set of movies, tv shows, writers, directors, and actors. https://www.imdb.com/interfaces/
  • 15. Jooby: HTTP API GraphQl & Rest ● GraphQL requires a single POST or GET endpoint ● Supports multi versioned REST endpoints ● Swagger and RAML generation for Rest ● Metrics, supporting graphite, data dog and more. ● Docker support ● A number of other modules ● Running on Netty an asynchronous event server ○ Can run on other servers. ● Support for hot reloading, i.e. automatic recompilation.
  • 16. There are a Plethora of HTTP Services Choose what works for you! ● Vertx ● DropWizard ● Javalin ● Spark ● Ktor ● I’m sure I’m forgetting something.
  • 17. Jooby Making End Points ● Closures, lambda functions included in a type safe DSL builder. ● Supports MVC class based method (My preference)
  • 18. Jooby Closure REST EndPoint ● A type safe builder for your end points in the run section for Jooby. ● Supports arguments and parameters. ● Each http verb is a seperate function
  • 19. Class MVC Rest EndPoint - Each Class is a path - Annotated with the HTTP verb - Can annotate with sub path - Automatic conversion to json
  • 20. Single GraphQL EndPoint - Data classes for response and post body. - Read the post body. - Submit to the schema executor - Return response.
  • 21. GraphQL Java ● Strong Community, very active development. ● Support for Apollo (minus caching) and Relay, plus more. ● A number of additions to ease development. ○ https://github.com/graphql-java/awesome-graphql-java ● Can design schema first or classes first. ● Automatic integration with spring.
  • 22. Limitations of GraphQL Java ● Kotlin is not a first class citizen. ● Builders, that feel a bit heavy in comparison to Kotlin Syntax. ● Documentation is a bit scarce. ● Wiring type definitions, to query resolvers is verbose. ● Doesn’t feel like idiomatic Kotlin ○ There is one Wrapper in Kotlin, but it is not overly active ● Enter GraphQL SPQR. ○ An annotation library that makes adding types and queries very simple. ○ The downside is it doesn’t support Kotlin Data Classes ■ Need to fall back to java in some instances. ■ May encounter esoteric bugs with annotations in Kotlin.
  • 23. GraphQL Object Definition ● Basic Java POJO ● Annotations for the Getters
  • 24. Or This Works ● Class constructor with annotations. ● Common class so can be used across platforms. ● This is the JVM implementation.
  • 26. Generating the Schema ● Instantiate the Pet Service a singleton ● Instantiate the schema, passing any singletons you develop.
  • 27. Demo Time ● Data store is using sample data from IMDB ● REST + GraphQL Endpoints ○ Hot Reloading ● Apollo Engine Integration ○ GraphQL Query Tracing ● Grafana showing Jooby metrics ● Docker build ● Maybe a kotlin + react fetching from the API.
  • 29. VertX If you’re looking for a highly concurrent distributed backend layer. Look at VertX. ● Works with an event loop, and worker pools. ○ Passing information through a message bus. ■ Which can be centralized ■ And accessed from a number of languages. ● Can start with just http endpoints and add more later. ● Built in clustering and service discovery. ● First class Kotlin support. ● Polyglot (Java, Kotlin, Groovy, Scala, Javascript, Ruby) ● HTTP end points, as well as custom TCP/UDP services. ● Akin to an actor model. ● Great GraphQL support.
  • 30. Changing your data store ● Neo4j (graph database has built in graphql support). ● In built use of GraphQL Java and Apollo ● But you have to change your data store… ● Called the Grand Stack
  • 31. Could we create new annotations?

Editor's Notes

  1. Show Jooq Build gradle in idea
  2. Walk through