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

Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 

Recently uploaded (20)

Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 

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