SlideShare a Scribd company logo
Intro to GraphQL for Database Developers
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Intro to GraphQL for Database Developers
Dan McGhan
Developer Advocate @Oracle
May 16, 2019
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, timing, and pricing of any
features or functionality described for Oracle’s products may change and remains at the
sole discretion of Oracle Corporation.
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
About me
• Dan McGhan
– Developer Advocate @Oracle
– Focus on JavaScript and Oracle Database
• Contact Info
– dan.mcghan@oracle.com
– @dmcghan
– jsao.io
4
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Agenda
Overview of GraphQL
Type system and query language
Demo
1
2
3
5
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Agenda
Overview of GraphQL
Type system and query language
Demo
1
2
3
6
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
What is GraphQL?
• A query language for APIs created by Facebook
– Designed to make APIs more flexible and efficient
• Consists of
– Type system
– Query language and execution semantics
– Static validation
– Type introspection
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
GraphQL history
• Internal Facebook project since 2012
• First specification released publicly in 2015
– Regular updates since then
• 2019: One of the hottest buzzwords in tech
8
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Spec vs. implementation
• Facebook publishes a spec and a reference implementation
– The spec describes how a GraphQL implementation should work
– GraphQL.js is the reference implementation in JavaScript
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Primary benefits of GraphQL
• Addresses under fetching
– Can get many resources in a single request
• Addresses over fetching
– Can project only what’s needed for the app
• Organization is based on types and fields rather than URL endpoints
– GraphQL servers have a single “smart” endpoint
• Evolve APIs without versions
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
REST vs GraphQL
REST GraphQL
Can send over HTTP Can send over HTTP
Can return JSON Can return JSON
Endpoint is the object identity Object identity is part of the query
Resource is determined by the server Server declares what is available, client
requests what it needs
May require loading from multiple URLs Gets all the data in a single request
GET or POST to same URL query{} and mutation{} use same URL
Calls are stateless Query and mutation operations are
stateless
11
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | 12
Web Browser Web Server Database
SQL
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | 13
Web Browser Web Server Database
SQLGraphQL
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Agenda
Overview of GraphQL
Type system and query language
Demo
1
2
3
14
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Type system
• Describes the objects that can be returned
– Schema Definition Language expresses the GraphQL schema shape and types
• Default scalar types
– ID, Int, Float, String, Boolean
• Other types
– Object, Interface, Union, Enum, Input Object, List, Directive
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Operation types
• Query
– Think: SELECT or Data Query Language (DQL)
• Mutation
– Think: Data Manipulation Language (DMLP
• Subscription
– Think: Continuous Query Notification (CQN)
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Let’s start with something we know…
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
EMP and DEPT DDL
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
EMP and DEPT as GraphQL schema language
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Adding a root object
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Rolling the query root into a schema
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
REST request/response
REST GET
/departments/1
22
REST Response
{
"deptno": 1,
"dname": "ACCOUNTING",
"loc": "NEW YORK"
}
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
GraphQL query/response
GraphQL Query
{
department(id: 1) {
deptno
dname
loc
}
}
23
Response
{
"data": {
"department": {
"deptno": 1,
"dname": "ACCOUNTING",
"loc": "NEW YORK"
}
}
}
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
GraphQL query/response
GraphQL Query 2
{
department(id: 1) {
deptno
dname
}
}
24
Response 2
{
"data": {
"department": {
"deptno": 1,
"dname": "ACCOUNTING" }
}
}
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Agenda
Overview of GraphQL
Type system and query language
Demo
1
2
3
25
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | 26
GraphQL Demo Technologies
‘GraphiQL’ UI express, express-graphql,
graphql, and node-oracledb
modules
Oracle Database
Queries and responses GraphQL requests over HTTP Persistence
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Closing thoughts
• REST isn’t going away anytime soon
– And it still has some advantages over GraphQL
• But GraphQL is like giving SQL to front-end developers
– We all know how powerful SQL is!
• Keep GraphQL on your radar
– Front-end devs will likely be asking for it soon…
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Where to go from here
• https://graphql.org/
– The “home” for GraphQL; great learning material
• https://www.howtographql.com
– Another excellent learning resource with videos
• https://graphql.github.io/graphql-spec/
– Specification
• https://goodapi.co/blog/rest-vs-graphql
– Fair, unbiased comparison of REST and GraphQL
Intro to GraphQL for Database Developers

More Related Content

Similar to Intro to GraphQL for Database Developers (20)

PDF
Modern APIs with GraphQL
Taikai
 
PDF
GraphQL
Deepak Shevani
 
PDF
GraphQL with .NET Core Microservices.pdf
Knoldus Inc.
 
PDF
GraphQL ♥︎ GraphDB
GraphRM
 
PDF
Marco Liberati - Graph analytics
Codemotion
 
PDF
GraphQL for Native Apps
Emanuele Di Saverio
 
PPTX
Introduction to GraphQL Presentation.pptx
Knoldus Inc.
 
PDF
Graphql
Niv Ben David
 
PPTX
GraphQL Introduction with Spring Boot
vipin kumar
 
PPT
Graphql presentation
Vibhor Grover
 
PDF
GraphQL the holy contract between client and server
Pavel Chertorogov
 
PPTX
GraphQL - The new "Lingua Franca" for API-Development
jexp
 
PPTX
Building a GraphQL API in PHP
Andrew Rota
 
PPTX
GraphQL API Gateway and microservices
Mohammed Shaban
 
PDF
Introduction to GraphQL
Knoldus Inc.
 
PPTX
GraphQl Introduction
AbhayKumarAgrawal1
 
PPTX
Graph QL Introduction
LivePerson
 
PPTX
Graphql
Girish Talekar
 
PDF
Andrea Baldon, Emanuele Di Saverio - GraphQL for Native Apps: the MyAXA case ...
Codemotion
 
PDF
GraphQL IndyJS April 2016
Brad Pillow
 
Modern APIs with GraphQL
Taikai
 
GraphQL with .NET Core Microservices.pdf
Knoldus Inc.
 
GraphQL ♥︎ GraphDB
GraphRM
 
Marco Liberati - Graph analytics
Codemotion
 
GraphQL for Native Apps
Emanuele Di Saverio
 
Introduction to GraphQL Presentation.pptx
Knoldus Inc.
 
Graphql
Niv Ben David
 
GraphQL Introduction with Spring Boot
vipin kumar
 
Graphql presentation
Vibhor Grover
 
GraphQL the holy contract between client and server
Pavel Chertorogov
 
GraphQL - The new "Lingua Franca" for API-Development
jexp
 
Building a GraphQL API in PHP
Andrew Rota
 
GraphQL API Gateway and microservices
Mohammed Shaban
 
Introduction to GraphQL
Knoldus Inc.
 
GraphQl Introduction
AbhayKumarAgrawal1
 
Graph QL Introduction
LivePerson
 
Andrea Baldon, Emanuele Di Saverio - GraphQL for Native Apps: the MyAXA case ...
Codemotion
 
GraphQL IndyJS April 2016
Brad Pillow
 

More from Daniel McGhan (10)

PDF
Intro to JavaScript for APEX Developers
Daniel McGhan
 
PPTX
Dynamic Actions, the Hard Parts
Daniel McGhan
 
PDF
Module 3: Working with the DOM and jQuery
Daniel McGhan
 
PDF
Module 2: Adding JavaScript to APEX Apps
Daniel McGhan
 
PDF
Module 1: JavaScript Basics
Daniel McGhan
 
PDF
Introduction to JavaScript for APEX Developers - Module 3: Working with the D...
Daniel McGhan
 
PDF
Introduction to JavaScript for APEX Developers - Module 2: Adding JavaScript ...
Daniel McGhan
 
PDF
Introduction to JavaScript for APEX Developers - Module 1: JavaScript Basics
Daniel McGhan
 
PPTX
JavaScript: Why Should I Care?
Daniel McGhan
 
PDF
JSON and Oracle Database: A Brave New World
Daniel McGhan
 
Intro to JavaScript for APEX Developers
Daniel McGhan
 
Dynamic Actions, the Hard Parts
Daniel McGhan
 
Module 3: Working with the DOM and jQuery
Daniel McGhan
 
Module 2: Adding JavaScript to APEX Apps
Daniel McGhan
 
Module 1: JavaScript Basics
Daniel McGhan
 
Introduction to JavaScript for APEX Developers - Module 3: Working with the D...
Daniel McGhan
 
Introduction to JavaScript for APEX Developers - Module 2: Adding JavaScript ...
Daniel McGhan
 
Introduction to JavaScript for APEX Developers - Module 1: JavaScript Basics
Daniel McGhan
 
JavaScript: Why Should I Care?
Daniel McGhan
 
JSON and Oracle Database: A Brave New World
Daniel McGhan
 
Ad

Recently uploaded (20)

PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Python basic programing language for automation
DanialHabibi2
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Ad

Intro to GraphQL for Database Developers

  • 2. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Intro to GraphQL for Database Developers Dan McGhan Developer Advocate @Oracle May 16, 2019
  • 3. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, timing, and pricing of any features or functionality described for Oracle’s products may change and remains at the sole discretion of Oracle Corporation.
  • 4. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | About me • Dan McGhan – Developer Advocate @Oracle – Focus on JavaScript and Oracle Database • Contact Info – [email protected] – @dmcghan – jsao.io 4
  • 5. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Agenda Overview of GraphQL Type system and query language Demo 1 2 3 5
  • 6. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Agenda Overview of GraphQL Type system and query language Demo 1 2 3 6
  • 7. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | What is GraphQL? • A query language for APIs created by Facebook – Designed to make APIs more flexible and efficient • Consists of – Type system – Query language and execution semantics – Static validation – Type introspection
  • 8. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | GraphQL history • Internal Facebook project since 2012 • First specification released publicly in 2015 – Regular updates since then • 2019: One of the hottest buzzwords in tech 8
  • 9. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Spec vs. implementation • Facebook publishes a spec and a reference implementation – The spec describes how a GraphQL implementation should work – GraphQL.js is the reference implementation in JavaScript
  • 10. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Primary benefits of GraphQL • Addresses under fetching – Can get many resources in a single request • Addresses over fetching – Can project only what’s needed for the app • Organization is based on types and fields rather than URL endpoints – GraphQL servers have a single “smart” endpoint • Evolve APIs without versions
  • 11. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | REST vs GraphQL REST GraphQL Can send over HTTP Can send over HTTP Can return JSON Can return JSON Endpoint is the object identity Object identity is part of the query Resource is determined by the server Server declares what is available, client requests what it needs May require loading from multiple URLs Gets all the data in a single request GET or POST to same URL query{} and mutation{} use same URL Calls are stateless Query and mutation operations are stateless 11
  • 12. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | 12 Web Browser Web Server Database SQL
  • 13. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | 13 Web Browser Web Server Database SQLGraphQL
  • 14. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Agenda Overview of GraphQL Type system and query language Demo 1 2 3 14
  • 15. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Type system • Describes the objects that can be returned – Schema Definition Language expresses the GraphQL schema shape and types • Default scalar types – ID, Int, Float, String, Boolean • Other types – Object, Interface, Union, Enum, Input Object, List, Directive
  • 16. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Operation types • Query – Think: SELECT or Data Query Language (DQL) • Mutation – Think: Data Manipulation Language (DMLP • Subscription – Think: Continuous Query Notification (CQN)
  • 17. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Let’s start with something we know…
  • 18. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | EMP and DEPT DDL
  • 19. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | EMP and DEPT as GraphQL schema language
  • 20. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Adding a root object
  • 21. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Rolling the query root into a schema
  • 22. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | REST request/response REST GET /departments/1 22 REST Response { "deptno": 1, "dname": "ACCOUNTING", "loc": "NEW YORK" }
  • 23. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | GraphQL query/response GraphQL Query { department(id: 1) { deptno dname loc } } 23 Response { "data": { "department": { "deptno": 1, "dname": "ACCOUNTING", "loc": "NEW YORK" } } }
  • 24. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | GraphQL query/response GraphQL Query 2 { department(id: 1) { deptno dname } } 24 Response 2 { "data": { "department": { "deptno": 1, "dname": "ACCOUNTING" } } }
  • 25. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Agenda Overview of GraphQL Type system and query language Demo 1 2 3 25
  • 26. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | 26 GraphQL Demo Technologies ‘GraphiQL’ UI express, express-graphql, graphql, and node-oracledb modules Oracle Database Queries and responses GraphQL requests over HTTP Persistence
  • 27. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Closing thoughts • REST isn’t going away anytime soon – And it still has some advantages over GraphQL • But GraphQL is like giving SQL to front-end developers – We all know how powerful SQL is! • Keep GraphQL on your radar – Front-end devs will likely be asking for it soon…
  • 28. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Where to go from here • https://graphql.org/ – The “home” for GraphQL; great learning material • https://www.howtographql.com – Another excellent learning resource with videos • https://graphql.github.io/graphql-spec/ – Specification • https://goodapi.co/blog/rest-vs-graphql – Fair, unbiased comparison of REST and GraphQL

Editor's Notes

  • #9: Adoption has been rapid since first public spec released in 2015 Specification unlike REST. Spec is Royalty free - Open Web Foundation Agreement (OWFa) v1.0 Regular spec updates. Current is June 2018 and no longer a ‘Draft RFC’. Contains the Schema Definition Language GraphQL is used in other languages, but this talk is about Node.js I’ve grabbed a few logos of companies using GraphQL from the graphql.org site and other public sources. Oracle is included – I know of at least one product group inside Oracle seriously using GraphQL internally.
  • #12: Gets all data....: Performance benefits from requiring a single request Stateless allows scaling via cloning of GraphQL server instances
  • #23: To set the scene of where we’ve come from, let’s look at a REST example A GET call is made to our endpoint for resource 2 <Click> Typically most new APIs give a JSON response If you’ll forgive my nursery tune joke and accept that AGE is a string, in this example we get ‘Old MacDonald’ as the payload I promise no more bad jokes.
  • #24: Let's look at GraphQL the 'graph query language'. Here we have a declarative query that is submitted, typically over HTTP This query with the root field ‘farmer' asks for the farmer with id of 2. Specifically it asks for the id, the name and the age of that farmer to be returned. <click> The GraphQL specification doesn’t say JSON has to be returned but in-line with REST usage, it typically is.
  • #25: Let's look at GraphQL the 'graph query language'. Here we have a declarative query that is submitted, typically over HTTP This query with the root field ‘farmer' asks for the farmer with id of 2. Specifically it asks for the id, the name and the age of that farmer to be returned. <click> The GraphQL specification doesn’t say JSON has to be returned but in-line with REST usage, it typically is.
  • #27: This is what the demo will do. We’ll make some GraphQL queries from a browser using the fantastic GraphiQL (pronounced Graphical) interface. These queries talk to our GraphQL server running in Node.js. The npm eco system has some excellent packages to work with GraphQL. Node.js uses Oracle’s open source node-oracledb module to query Oracle Database. In this particular example I’m using Oracle’s newish Document storage APIs “Simple Oracle Document Acces" or SODA. By default SODA documents are JSON, making it perfect for working with GraphQL (or REST for that matter). I’ll talk a bit more about SODA in a few slides. Note I could easily have used Oracle DB 12.1.0.2’s native JSON functionality, or even manually constructed JSON strings by using standard SQL.