SlideShare a Scribd company logo
1 of 44
Download to read offline
GraphQL 101
1#engageug
Paul Withers
ICS Consultant, Intec Systems Ltd
IBM Champion since 2011
OpenNTF Board Member
WWS Java SDK developer
2#engageug
Philippe Riand
CTO of Trilog Group & Darwino Inc.
Former application development
chief architect for
IBM Collaboration Services
Chief architect, and inventor,
of IBM Domino XPages
3#engageug
The Problem With REST
Multiple calls required
• “Joins” are consumer’s responsibility
• May result in a large number of REST calls –> Latency is multiplied by
the number of calls -> sequential behaviour
Provider-driven
• Consumer gets what they get, needs to parse accordingly
Versions
• Changes typically require version increment
• May affect consumer’s application object model
Validation
• Request cannot be validated prior to submission
4#engageug
Enter GraphQL
5#engageug
What Is GraphQL?
Created by Facebook 2012
Specification for standard began 2015
Query language
• Not database architecture
• Not programming language
• A modern way to expose your API and give your clients more Control
on what they get
6#engageug
Why GraphQL?
Consumer-driven
• Returns what the client asks for and no more!
Hierarchical
• Query and response are both JSON, in same hierarchical structure
Strongly Typed
• GraphQL type structure ensures query can be tested for syntactical
correctness and validity before execution
Introspective
• GraphQL language can be used to query the type structure
7#engageug
GraphQL
• Open source in-browser IDE https://github.com/graphql/graphiql
• Build validated and syntactically correct queries /
mutations and fragments
• Define query variables
• Run queries and browse response
• Run a query to introspect schema
• Drill down through schema documentation
• Visualizer tools also available
http://nathanrandal.com/graphql-visualizer/
8#engageug
GraphiQL
9#engageug
GraphQL and Watson Work Services
• Documentation online
https://workspace.ibm.com/developer/docs
• GraphiQL tool for WWS
https://workspace.ibm.com/graphql
• Must be authenticated in browser to Watson Workspace first!
• Queries run as user, not application
• Some queries are not available to applications
• Additional REST endpoints exist (e.g. authentication,
focus, photos)
• These are usually version-based, e.g. …/v1/…
10#engageug
GraphQL Queries (GET Requests)
11#engageug
GraphQL Query Structure
Query can have operation name, optional if only one query
Query object has fields for things that can be returned
Fields may take (or require) arguments
• Arguments have a type (String, Int, ID etc)
• See GraphQL documentation for more details
• Required arguments have “!” after the type in documentation (e.g.
space(id:ID!)
• Argument values may be literal or map to variables
12#engageug
GraphQL Query Structure
Variables
• Passed as an argument of the operation name
• Format is “$VariableName: Type” (e.g. $FIRST: Int)
• Passed to value of an argument in the operation
• Declared as a separate JSON object
• Key is variable name as a String
• Value is variable value
• Validated in GraphiQL IDE, like rest of query
13#engageug
GraphQL Query Structure
Fields may have an alias
• Format is “alias: field”
• Allows query to retrieve multiple result objects of same field type
• In response, field type is replaced with alias
Fields will themselves have fields and/or objects to return
14#engageug
GraphQL Query Structure
Queries on lists may return lots of objects
“Slice” using first and last
Return pageInfo object to get cursor
Pass cursor back to query using before or after
15#engageug
GraphQL Query Structure
Fragments can be included to improve readability of
complex queries
• Defined as separate JSON object
• Format is “fragment fragmentName on type”
• Allows fields to be defined and validated inline
• Used with format “…fragmentName”
Schema may return an interface or union type
• Inline fragment may be required to act differently depending on
actual implementation from interface
• Format is “… on type”
• Not used in WWS, see GraphQL documentation for examples
16#engageug
Query Fragments
17#engageug
GraphQL Query Structure
Directives allow dynamic manipulation of the query based
on variables
• @include(if: Boolean)
• @skip(if: Boolean)
18#engageug
GraphQL MUTATIONS (PUT, POST, PATCH, DELETE Requests)
19#engageug
GraphQL Mutations
Mutation can have an operation name
Declares the field to set (function)
Pass an input object to the field
Returns a type
• May just be a scalar (e.g. true / false)
• May be an object (e.g. a space)
• If an object, that can be queried, as in a query
Can pass multiple fields (processed sequentially)
20#engageug
GraphQL Subscriptions
Subscription allows clients to receive updates
Declares the field to subscribe to
Pass an input object to the field, including subscription id
Nothing yet implemented for this in Watson Work Services
21#engageug
Introspecting GraphQL Schema
GraphQL schema can be introspected with GraphQL query!
• __schema queries the schema
• __type introspects a specific type
• kind introspects field type
• If NON_NULL, ofType returns its actual type
“It’s GraphQL queries all the way down”
22#engageug
GraphQL – Real World Implementations
- Facebook
- Watson Works Services
- Darwino (OpenSource Project hosted on OpenNTF and
darwino.org)
- Connections Pink
23#engageug
Darwino GraphQL Implementation
Darwino is providing a set of open source libraries for both
consumers and producers of GraphQL
The libraries are part of the Darwino core code but hosted
on OpenNTF/darwino.org
The code depends on some core Darwino classes (JSON,
utilities…) but these are part of Darwino community edition
24#engageug
Schemaless GraphQL Queries
GraphQL uses static schemas to validate the queries and
make them discoverable by tools (code completion…)
This forces the queries to be fully defined on the producer
side
All the fields have to be predefined
All the relations between data sets have to be predefined as well
What about semi structured data, like Domino documents?
-> Would benefit from more flexibility
To seamlessly access the data in an unstructured document
To make prototyping easier and faster
To traverse relations that are not known upfront
25#engageug
Dynamic JSON Data Type
A JSON data type is a GraphQL type that exposes its
content as a virtual JSON Object
Its dynamic content is accessed using pseudo fields extract
the value using JSON Path
26#engageug
A Simple Domino Example
Reading items from an existing Domino document
DominoDocument is a pseudo field loading a document
based on parameters, and returning a JSON data type
string is a pseudo field extracting a string value from a
JSON data type using a JSON path
27#engageug
doc: DominoDocument(database:"DarwinoReports.nsf",
unid:"DD2028D6B53ADCCB852581080009C40E") {
_unid,
code: string(path:"PRODUCTCODE"),
name: string(path:"PRODUCTNAME"),
}
https://playground.darwino.com/playground.nsf/GraphqlSnippets.xsp#snippet=Notes_Domino_Read_Document
Dynamic JSON Types
Dynamic JSON types are pseudo fields that can be added
any object
By convention, these fields start with a capital letter, like a
class in Java: DominoDocument, DominoView…
They are used with an alias to name the result field
Dynamic types are contributed by extension points,then
added to every type in the final GraphQL schema.
28#engageug
view: DominoView(name: “myview”){
…
doc: DominoDocument(unid: ‘xxx’) {
…
}
}
Dynamic JSON Fields
Dynamic fields are also peudo fields, extracting a value
using a JSON path and coercing the result to the desired
type:
New dynamic fields can be added by the developers
29#engageug
val: string(path:“a.b.c")
val: number(path:“a.b.c")
val: int:“a.b.c")
val: long(path:“a.b.c")
val: boolean(path:“a.b.c")
val: value(path:“a.b.c")
val: eval(formula:“@Trim(@UserName)")
JSON Path Introduction
A JSON Path is to JSON what an XPath is to XML
The syntax is closed to JavaScript, starting with a ‘$’
$.firstName
$.spouse.firstName
$.spouse[‘firstName’]
$.addresses[1].street
$ {whole document}
There are more complex operators
http://goessner.net/articles/JsonPath/
Darwino core provides a high performance, advanced
JSON Path engine
30#engageug
{
firstName: ‘Barak’,
spouse: {
firstName: ‘Michele’,
…
}
addresses: [
{ street: ‘Main St’, …},
{ street: ‘Bob Sq’, …},
],
…
}
Static Fields
A JSON dynamic type can mix and match static fields with
dynamic ones
By convention, system fields start with a ‘_’ (_unid, …)
Functional static fields can be added
31#engageug
DominoDocument(database:"DarwinoReports.nsf",
unid:"DD2028D6B53ADCCB852581080009C40E") {
_unid,
_noteId,
_created,
_lastAccessed,
user {
cn, dn
}
name: string(path:"PRODUCTNAME"),
}
Passing Parameters to JSON Types
In the previous Domino example, the unid parameter is
hard coded which is not that useful…
unid can be set from a GraphQL variable, but this is also
global to the request – cannot be used for relations
Darwino implementation uses a special syntax to calculate
parameters
Delegates the evaluation of ‘docid’ to the parent object
Drawback: all parameters have to be declared as strings in GraphQL
32#engageug
doc: DominoDocument(unid:$VAR)
doc: DominoDocument(unid:”${docid}”)
Parameters Example
33#engageug
doc: CursorDocument(database:"playground", store:"owners") {
dn: string(path:"dn"),
firstName: string(path:"firstName"),
lastName: string(path:"lastName"),
pinballs: objectArray(path:"pinballs[*]") {
pinball: Document(unid:"${ipdb}",database:"playground", store:"pinball") {
name: string(path:"name"),
manufacturer: string(path:"manufacturer"),
released: number(path:"released"),
players: long(path:"players"),
flippers: int(path:"flippers")
}
}
}
https://playground.darwino.com/playground.nsf/GraphqlSnippets.xsp#snippet=Json_St
ore_Document_Document_join_on_Unid
Mixing Content
Mixing JSON documents with Users coming from LDAP
34#engageug
docs: CursorDocuments(database:"playground", store:"owners“) {
dn: string(path:"dn"),
firstName: string(path:"firstName"),
user:User(dn:"${dn}") {
dn,
cn,
email
}
https://playground.darwino.com/playground.nsf/GraphqlSnippets.xsp#snippet=Mixed
_Document_join_on_User_Directory___Unid
Java Client Builder
• A GraphQL query is a text file that is always painful to
build safely
• Escaping the text pieces, quotes…
• Making sure that all the braces { } are balanced
• Format it to be either compacted or developer friendly
• Darwino provides an easy to use builder to help the
creation of queries in Java
• Highly readable by developer
• Supports code completion in a Java IDE
• Based on the Java Builder pattern
• Fully extensible to handle known objects
35#engageug
A Simple GraphQL Query
36#engageug
query MyQuery {
field1
name: field2
field3(p=‘3’) {
subfield
}
}
String q = new GQuery("MyQuery")
.field("field1")
.field(“name", "field2")
.field(new GField(field3) {
.attribute(“p”,”3”)
.field(“subfield")
})
.build();
Example from the Playground
Putting it altogether…
37#engageug
String q = new GQuery("example")
.field(new GField("Document")
.attribute("unid", "1000")
.attribute("database", "playground")
.attribute("store", "pinball")
.field("_id")
.field("_unid")
.field("_cdate")
.field("_muser")
.stringField("name","name")
.stringField("manufacturer","manufacturer")
.numberField("released","released")
.longField("players","players")
.intField("flippers","flippers")
).build();
https://playground.darwino.com/playground.nsf/JavaSnippets.xsp#snippet=GraphQL_Run_Inline_Client_Query
Watson Work Services Java SDK
Java SDK for Watson Work Service
• On OpenCode4Workspace (run by OpenNTF)
• Download the project
• Consume from Maven
<dependency>
<groupId>org.opencode4workspace.watson-work-services</groupId>
<artifactId>wws-api</artifactId>
<version>0.6.0</version>
</dependency>
• View source code on Stash (includes Junit tests)
• Explore implementation in Watson Workspace for Eclipse / Notes
Latest documentation on OpenNTF Wiki, Javadoc available
38#engageug
Watson Work Services Java SDK
Client authentication as application
Client authentication as user
Build queries with Java objects, methods and enums
• No need to construct queries as complex Strings
Methods to output built query as String and response as
String
Conversion of response to Java objects
Methods to parse error responses
Standard REST endpoints also supported
39#engageug
WWS Java SDK Samples
40#engageug
WWS Java SDK Samples
41#engageug
WWS Java SDK
Variables not current supported
• Use Java method to construct query based on variable
Fragments not currently supported
• Use Java method / object to specify standard fields
Directives not currently supported
• Use Java method to construct query based on variable
Aliases not currently supported
• Track the JIRA issue
42#engageug
Resources
GraphQL website, http://graphql.org
GraphQL community resources, http://graphql.org/community/
GraphQL Visualization Tool, http://nathanrandal.com/graphql-
visualizer/
WWS developer documentation,
https://workspace.ibm.com/developer/docs
WWS GraphiQL IDE, https://workspace.ibm.com/graphql
WWS API Java SDK,
https://openntf.org/main.nsf/project.xsp?r=project/Watson%20
Work%20Services%20Java%20SDK
43#engageug
Thank You
44#engageug
Paul Withers
Intec Systems Ltd & OpenNTF
pwithers@intec.co.uk
@paulswithers
https://www.intec.co.uk/blog
https://paulswithers.github.io
Philippe Riand
Darwino Inc.
phil@darwino.com
@philriand
http://blog.riand.com/
https://www.darwino.com/

More Related Content

What's hot

Real scenario: moving a legacy app to the Cloud
Real scenario: moving a legacy app to the CloudReal scenario: moving a legacy app to the Cloud
Real scenario: moving a legacy app to the CloudStefano Paluello
 
Rapid Web API development with Kotlin and Ktor
Rapid Web API development with Kotlin and KtorRapid Web API development with Kotlin and Ktor
Rapid Web API development with Kotlin and KtorTrayan Iliev
 
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017Codemotion
 
Using MongoDB with the .Net Framework
Using MongoDB with the .Net FrameworkUsing MongoDB with the .Net Framework
Using MongoDB with the .Net FrameworkStefano Paluello
 
AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)Igor Talevski
 
C# advanced topics and future - C#5
C# advanced topics and future - C#5C# advanced topics and future - C#5
C# advanced topics and future - C#5Peter Gfader
 
APIdays Paris 2018 - Building scalable, type-safe GraphQL servers from scratc...
APIdays Paris 2018 - Building scalable, type-safe GraphQL servers from scratc...APIdays Paris 2018 - Building scalable, type-safe GraphQL servers from scratc...
APIdays Paris 2018 - Building scalable, type-safe GraphQL servers from scratc...apidays
 
Introduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course Ahmedabad
Introduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course AhmedabadIntroduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course Ahmedabad
Introduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course AhmedabadNicheTech Com. Solutions Pvt. Ltd.
 
Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code firstConfiz
 
Data Persistence in Android with Room Library
Data Persistence in Android with Room LibraryData Persistence in Android with Room Library
Data Persistence in Android with Room LibraryReinvently
 
Object- Relational Persistence in Smalltalk
Object- Relational Persistence in SmalltalkObject- Relational Persistence in Smalltalk
Object- Relational Persistence in SmalltalkESUG
 
Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code FirstJames Johnson
 

What's hot (20)

LINQ
LINQLINQ
LINQ
 
Entity Framework 4
Entity Framework 4Entity Framework 4
Entity Framework 4
 
Introducing LINQ
Introducing LINQIntroducing LINQ
Introducing LINQ
 
Real scenario: moving a legacy app to the Cloud
Real scenario: moving a legacy app to the CloudReal scenario: moving a legacy app to the Cloud
Real scenario: moving a legacy app to the Cloud
 
LINQ in C#
LINQ in C#LINQ in C#
LINQ in C#
 
Rapid Web API development with Kotlin and Ktor
Rapid Web API development with Kotlin and KtorRapid Web API development with Kotlin and Ktor
Rapid Web API development with Kotlin and Ktor
 
Linq to sql
Linq to sqlLinq to sql
Linq to sql
 
Understanding linq
Understanding linqUnderstanding linq
Understanding linq
 
Linq
LinqLinq
Linq
 
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017
 
Getting started with entity framework
Getting started with entity framework Getting started with entity framework
Getting started with entity framework
 
Using MongoDB with the .Net Framework
Using MongoDB with the .Net FrameworkUsing MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
 
AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)
 
C# advanced topics and future - C#5
C# advanced topics and future - C#5C# advanced topics and future - C#5
C# advanced topics and future - C#5
 
APIdays Paris 2018 - Building scalable, type-safe GraphQL servers from scratc...
APIdays Paris 2018 - Building scalable, type-safe GraphQL servers from scratc...APIdays Paris 2018 - Building scalable, type-safe GraphQL servers from scratc...
APIdays Paris 2018 - Building scalable, type-safe GraphQL servers from scratc...
 
Introduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course Ahmedabad
Introduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course AhmedabadIntroduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course Ahmedabad
Introduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course Ahmedabad
 
Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code first
 
Data Persistence in Android with Room Library
Data Persistence in Android with Room LibraryData Persistence in Android with Room Library
Data Persistence in Android with Room Library
 
Object- Relational Persistence in Smalltalk
Object- Relational Persistence in SmalltalkObject- Relational Persistence in Smalltalk
Object- Relational Persistence in Smalltalk
 
Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code First
 

Similar to GraphQL 101

Let's start GraphQL: structure, behavior, and architecture
Let's start GraphQL: structure, behavior, and architectureLet's start GraphQL: structure, behavior, and architecture
Let's start GraphQL: structure, behavior, and architectureAndrii Gakhov
 
GraphQL the holy contract between client and server
GraphQL the holy contract between client and serverGraphQL the holy contract between client and server
GraphQL the holy contract between client and serverPavel Chertorogov
 
GraphQL in an Age of REST
GraphQL in an Age of RESTGraphQL in an Age of REST
GraphQL in an Age of RESTYos Riady
 
Data Types/Structures in DivConq
Data Types/Structures in DivConqData Types/Structures in DivConq
Data Types/Structures in DivConqeTimeline, LLC
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffSpring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffJAX London
 
Field injection, type safe configuration, and more new goodies in Declarative...
Field injection, type safe configuration, and more new goodies in Declarative...Field injection, type safe configuration, and more new goodies in Declarative...
Field injection, type safe configuration, and more new goodies in Declarative...bjhargrave
 
Tutorial: Building a GraphQL API in PHP
Tutorial: Building a GraphQL API in PHPTutorial: Building a GraphQL API in PHP
Tutorial: Building a GraphQL API in PHPAndrew Rota
 
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) Extension
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) ExtensionSimplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) Extension
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) ExtensionVMware Tanzu
 
OpenDaylight and YANG
OpenDaylight and YANGOpenDaylight and YANG
OpenDaylight and YANGCoreStack
 
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScript
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScriptMongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScript
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScriptMongoDB
 
MongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and Typescript
MongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and TypescriptMongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and Typescript
MongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and TypescriptMongoDB
 
GraphQL and its schema as a universal layer for database access
GraphQL and its schema as a universal layer for database accessGraphQL and its schema as a universal layer for database access
GraphQL and its schema as a universal layer for database accessConnected Data World
 
Nick Raienko ''Service-oriented GraphQL''
Nick Raienko ''Service-oriented GraphQL''Nick Raienko ''Service-oriented GraphQL''
Nick Raienko ''Service-oriented GraphQL''OdessaJS Conf
 
Composable Parallel Processing in Apache Spark and Weld
Composable Parallel Processing in Apache Spark and WeldComposable Parallel Processing in Apache Spark and Weld
Composable Parallel Processing in Apache Spark and WeldDatabricks
 

Similar to GraphQL 101 (20)

Life outside WO
Life outside WOLife outside WO
Life outside WO
 
GraphQL 101
GraphQL 101GraphQL 101
GraphQL 101
 
Let's start GraphQL: structure, behavior, and architecture
Let's start GraphQL: structure, behavior, and architectureLet's start GraphQL: structure, behavior, and architecture
Let's start GraphQL: structure, behavior, and architecture
 
Scala and Spring
Scala and SpringScala and Spring
Scala and Spring
 
GraphQL the holy contract between client and server
GraphQL the holy contract between client and serverGraphQL the holy contract between client and server
GraphQL the holy contract between client and server
 
GraphQL in an Age of REST
GraphQL in an Age of RESTGraphQL in an Age of REST
GraphQL in an Age of REST
 
Data Types/Structures in DivConq
Data Types/Structures in DivConqData Types/Structures in DivConq
Data Types/Structures in DivConq
 
Google cloud Dataflow & Apache Flink
Google cloud Dataflow & Apache FlinkGoogle cloud Dataflow & Apache Flink
Google cloud Dataflow & Apache Flink
 
Graphql usage
Graphql usageGraphql usage
Graphql usage
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffSpring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard Wolff
 
Field injection, type safe configuration, and more new goodies in Declarative...
Field injection, type safe configuration, and more new goodies in Declarative...Field injection, type safe configuration, and more new goodies in Declarative...
Field injection, type safe configuration, and more new goodies in Declarative...
 
Tutorial: Building a GraphQL API in PHP
Tutorial: Building a GraphQL API in PHPTutorial: Building a GraphQL API in PHP
Tutorial: Building a GraphQL API in PHP
 
GraphQL + relay
GraphQL + relayGraphQL + relay
GraphQL + relay
 
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) Extension
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) ExtensionSimplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) Extension
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) Extension
 
OpenDaylight and YANG
OpenDaylight and YANGOpenDaylight and YANG
OpenDaylight and YANG
 
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScript
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScriptMongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScript
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScript
 
MongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and Typescript
MongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and TypescriptMongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and Typescript
MongoDB.local Berlin: Building a GraphQL API with MongoDB, Prisma and Typescript
 
GraphQL and its schema as a universal layer for database access
GraphQL and its schema as a universal layer for database accessGraphQL and its schema as a universal layer for database access
GraphQL and its schema as a universal layer for database access
 
Nick Raienko ''Service-oriented GraphQL''
Nick Raienko ''Service-oriented GraphQL''Nick Raienko ''Service-oriented GraphQL''
Nick Raienko ''Service-oriented GraphQL''
 
Composable Parallel Processing in Apache Spark and Weld
Composable Parallel Processing in Apache Spark and WeldComposable Parallel Processing in Apache Spark and Weld
Composable Parallel Processing in Apache Spark and Weld
 

More from Paul Withers

Engage 2019: Introduction to Node-Red
Engage 2019: Introduction to Node-RedEngage 2019: Introduction to Node-Red
Engage 2019: Introduction to Node-RedPaul Withers
 
Engage 2019: Modernising Your Domino and XPages Applications
Engage 2019: Modernising Your Domino and XPages Applications Engage 2019: Modernising Your Domino and XPages Applications
Engage 2019: Modernising Your Domino and XPages Applications Paul Withers
 
Engage 2019: AI What Is It Good For
Engage 2019: AI What Is It Good ForEngage 2019: AI What Is It Good For
Engage 2019: AI What Is It Good ForPaul Withers
 
Social Connections 14 - ICS Integration with Node-RED and Open Source
Social Connections 14 - ICS Integration with Node-RED and Open SourceSocial Connections 14 - ICS Integration with Node-RED and Open Source
Social Connections 14 - ICS Integration with Node-RED and Open SourcePaul Withers
 
ICONUK 2018 - Do You Wanna Build a Chatbot
ICONUK 2018 - Do You Wanna Build a ChatbotICONUK 2018 - Do You Wanna Build a Chatbot
ICONUK 2018 - Do You Wanna Build a ChatbotPaul Withers
 
IBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClassIBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClassPaul Withers
 
IBM Think Session 3249 Watson Work Services Java SDK
IBM Think Session 3249 Watson Work Services Java SDKIBM Think Session 3249 Watson Work Services Java SDK
IBM Think Session 3249 Watson Work Services Java SDKPaul Withers
 
OpenNTF Domino API (ODA): Super-Charging Domino Development
OpenNTF Domino API (ODA): Super-Charging Domino DevelopmentOpenNTF Domino API (ODA): Super-Charging Domino Development
OpenNTF Domino API (ODA): Super-Charging Domino DevelopmentPaul Withers
 
AD1279 "Marty, You're Not Thinking Fourth Dimensionally" - Troubleshooting XP...
AD1279 "Marty, You're Not Thinking Fourth Dimensionally" - Troubleshooting XP...AD1279 "Marty, You're Not Thinking Fourth Dimensionally" - Troubleshooting XP...
AD1279 "Marty, You're Not Thinking Fourth Dimensionally" - Troubleshooting XP...Paul Withers
 
Social Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoSocial Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoPaul Withers
 
ICON UK 2015 - ODA and CrossWorlds
ICON UK 2015 - ODA and CrossWorldsICON UK 2015 - ODA and CrossWorlds
ICON UK 2015 - ODA and CrossWorldsPaul Withers
 
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...Paul Withers
 
IBM ConnectED 2015 - MAS103 XPages Performance and Scalability
IBM ConnectED 2015 - MAS103 XPages Performance and ScalabilityIBM ConnectED 2015 - MAS103 XPages Performance and Scalability
IBM ConnectED 2015 - MAS103 XPages Performance and ScalabilityPaul Withers
 
OpenNTF Domino API - Overview Introduction
OpenNTF Domino API - Overview IntroductionOpenNTF Domino API - Overview Introduction
OpenNTF Domino API - Overview IntroductionPaul Withers
 
What's New and Next in OpenNTF Domino API (ICON UK 2014)
What's New and Next in OpenNTF Domino API (ICON UK 2014)What's New and Next in OpenNTF Domino API (ICON UK 2014)
What's New and Next in OpenNTF Domino API (ICON UK 2014)Paul Withers
 
From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Lib...
From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Lib...From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Lib...
From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Lib...Paul Withers
 
Engage 2014 OpenNTF Domino API Slides
Engage 2014 OpenNTF Domino API SlidesEngage 2014 OpenNTF Domino API Slides
Engage 2014 OpenNTF Domino API SlidesPaul Withers
 
IBM Connect 2014 BP204: It's Not Infernal: Dante's Nine Circles of XPages Heaven
IBM Connect 2014 BP204: It's Not Infernal: Dante's Nine Circles of XPages HeavenIBM Connect 2014 BP204: It's Not Infernal: Dante's Nine Circles of XPages Heaven
IBM Connect 2014 BP204: It's Not Infernal: Dante's Nine Circles of XPages HeavenPaul Withers
 
Embracing the power of the notes client
Embracing the power of the notes clientEmbracing the power of the notes client
Embracing the power of the notes clientPaul Withers
 
Beyond Domino Designer
Beyond Domino DesignerBeyond Domino Designer
Beyond Domino DesignerPaul Withers
 

More from Paul Withers (20)

Engage 2019: Introduction to Node-Red
Engage 2019: Introduction to Node-RedEngage 2019: Introduction to Node-Red
Engage 2019: Introduction to Node-Red
 
Engage 2019: Modernising Your Domino and XPages Applications
Engage 2019: Modernising Your Domino and XPages Applications Engage 2019: Modernising Your Domino and XPages Applications
Engage 2019: Modernising Your Domino and XPages Applications
 
Engage 2019: AI What Is It Good For
Engage 2019: AI What Is It Good ForEngage 2019: AI What Is It Good For
Engage 2019: AI What Is It Good For
 
Social Connections 14 - ICS Integration with Node-RED and Open Source
Social Connections 14 - ICS Integration with Node-RED and Open SourceSocial Connections 14 - ICS Integration with Node-RED and Open Source
Social Connections 14 - ICS Integration with Node-RED and Open Source
 
ICONUK 2018 - Do You Wanna Build a Chatbot
ICONUK 2018 - Do You Wanna Build a ChatbotICONUK 2018 - Do You Wanna Build a Chatbot
ICONUK 2018 - Do You Wanna Build a Chatbot
 
IBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClassIBM Think Session 8598 Domino and JavaScript Development MasterClass
IBM Think Session 8598 Domino and JavaScript Development MasterClass
 
IBM Think Session 3249 Watson Work Services Java SDK
IBM Think Session 3249 Watson Work Services Java SDKIBM Think Session 3249 Watson Work Services Java SDK
IBM Think Session 3249 Watson Work Services Java SDK
 
OpenNTF Domino API (ODA): Super-Charging Domino Development
OpenNTF Domino API (ODA): Super-Charging Domino DevelopmentOpenNTF Domino API (ODA): Super-Charging Domino Development
OpenNTF Domino API (ODA): Super-Charging Domino Development
 
AD1279 "Marty, You're Not Thinking Fourth Dimensionally" - Troubleshooting XP...
AD1279 "Marty, You're Not Thinking Fourth Dimensionally" - Troubleshooting XP...AD1279 "Marty, You're Not Thinking Fourth Dimensionally" - Troubleshooting XP...
AD1279 "Marty, You're Not Thinking Fourth Dimensionally" - Troubleshooting XP...
 
Social Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoSocial Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and Domino
 
ICON UK 2015 - ODA and CrossWorlds
ICON UK 2015 - ODA and CrossWorldsICON UK 2015 - ODA and CrossWorlds
ICON UK 2015 - ODA and CrossWorlds
 
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
 
IBM ConnectED 2015 - MAS103 XPages Performance and Scalability
IBM ConnectED 2015 - MAS103 XPages Performance and ScalabilityIBM ConnectED 2015 - MAS103 XPages Performance and Scalability
IBM ConnectED 2015 - MAS103 XPages Performance and Scalability
 
OpenNTF Domino API - Overview Introduction
OpenNTF Domino API - Overview IntroductionOpenNTF Domino API - Overview Introduction
OpenNTF Domino API - Overview Introduction
 
What's New and Next in OpenNTF Domino API (ICON UK 2014)
What's New and Next in OpenNTF Domino API (ICON UK 2014)What's New and Next in OpenNTF Domino API (ICON UK 2014)
What's New and Next in OpenNTF Domino API (ICON UK 2014)
 
From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Lib...
From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Lib...From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Lib...
From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Lib...
 
Engage 2014 OpenNTF Domino API Slides
Engage 2014 OpenNTF Domino API SlidesEngage 2014 OpenNTF Domino API Slides
Engage 2014 OpenNTF Domino API Slides
 
IBM Connect 2014 BP204: It's Not Infernal: Dante's Nine Circles of XPages Heaven
IBM Connect 2014 BP204: It's Not Infernal: Dante's Nine Circles of XPages HeavenIBM Connect 2014 BP204: It's Not Infernal: Dante's Nine Circles of XPages Heaven
IBM Connect 2014 BP204: It's Not Infernal: Dante's Nine Circles of XPages Heaven
 
Embracing the power of the notes client
Embracing the power of the notes clientEmbracing the power of the notes client
Embracing the power of the notes client
 
Beyond Domino Designer
Beyond Domino DesignerBeyond Domino Designer
Beyond Domino Designer
 

Recently uploaded

Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
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
 
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
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
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
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
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
 
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
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
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
 
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
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
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
 

Recently uploaded (20)

Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
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
 
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...
 
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...
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
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
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
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...
 
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...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
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
 
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
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
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
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
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 - ...
 

GraphQL 101

  • 2. Paul Withers ICS Consultant, Intec Systems Ltd IBM Champion since 2011 OpenNTF Board Member WWS Java SDK developer 2#engageug
  • 3. Philippe Riand CTO of Trilog Group & Darwino Inc. Former application development chief architect for IBM Collaboration Services Chief architect, and inventor, of IBM Domino XPages 3#engageug
  • 4. The Problem With REST Multiple calls required • “Joins” are consumer’s responsibility • May result in a large number of REST calls –> Latency is multiplied by the number of calls -> sequential behaviour Provider-driven • Consumer gets what they get, needs to parse accordingly Versions • Changes typically require version increment • May affect consumer’s application object model Validation • Request cannot be validated prior to submission 4#engageug
  • 6. What Is GraphQL? Created by Facebook 2012 Specification for standard began 2015 Query language • Not database architecture • Not programming language • A modern way to expose your API and give your clients more Control on what they get 6#engageug
  • 7. Why GraphQL? Consumer-driven • Returns what the client asks for and no more! Hierarchical • Query and response are both JSON, in same hierarchical structure Strongly Typed • GraphQL type structure ensures query can be tested for syntactical correctness and validity before execution Introspective • GraphQL language can be used to query the type structure 7#engageug
  • 8. GraphQL • Open source in-browser IDE https://github.com/graphql/graphiql • Build validated and syntactically correct queries / mutations and fragments • Define query variables • Run queries and browse response • Run a query to introspect schema • Drill down through schema documentation • Visualizer tools also available http://nathanrandal.com/graphql-visualizer/ 8#engageug
  • 10. GraphQL and Watson Work Services • Documentation online https://workspace.ibm.com/developer/docs • GraphiQL tool for WWS https://workspace.ibm.com/graphql • Must be authenticated in browser to Watson Workspace first! • Queries run as user, not application • Some queries are not available to applications • Additional REST endpoints exist (e.g. authentication, focus, photos) • These are usually version-based, e.g. …/v1/… 10#engageug
  • 11. GraphQL Queries (GET Requests) 11#engageug
  • 12. GraphQL Query Structure Query can have operation name, optional if only one query Query object has fields for things that can be returned Fields may take (or require) arguments • Arguments have a type (String, Int, ID etc) • See GraphQL documentation for more details • Required arguments have “!” after the type in documentation (e.g. space(id:ID!) • Argument values may be literal or map to variables 12#engageug
  • 13. GraphQL Query Structure Variables • Passed as an argument of the operation name • Format is “$VariableName: Type” (e.g. $FIRST: Int) • Passed to value of an argument in the operation • Declared as a separate JSON object • Key is variable name as a String • Value is variable value • Validated in GraphiQL IDE, like rest of query 13#engageug
  • 14. GraphQL Query Structure Fields may have an alias • Format is “alias: field” • Allows query to retrieve multiple result objects of same field type • In response, field type is replaced with alias Fields will themselves have fields and/or objects to return 14#engageug
  • 15. GraphQL Query Structure Queries on lists may return lots of objects “Slice” using first and last Return pageInfo object to get cursor Pass cursor back to query using before or after 15#engageug
  • 16. GraphQL Query Structure Fragments can be included to improve readability of complex queries • Defined as separate JSON object • Format is “fragment fragmentName on type” • Allows fields to be defined and validated inline • Used with format “…fragmentName” Schema may return an interface or union type • Inline fragment may be required to act differently depending on actual implementation from interface • Format is “… on type” • Not used in WWS, see GraphQL documentation for examples 16#engageug
  • 18. GraphQL Query Structure Directives allow dynamic manipulation of the query based on variables • @include(if: Boolean) • @skip(if: Boolean) 18#engageug
  • 19. GraphQL MUTATIONS (PUT, POST, PATCH, DELETE Requests) 19#engageug
  • 20. GraphQL Mutations Mutation can have an operation name Declares the field to set (function) Pass an input object to the field Returns a type • May just be a scalar (e.g. true / false) • May be an object (e.g. a space) • If an object, that can be queried, as in a query Can pass multiple fields (processed sequentially) 20#engageug
  • 21. GraphQL Subscriptions Subscription allows clients to receive updates Declares the field to subscribe to Pass an input object to the field, including subscription id Nothing yet implemented for this in Watson Work Services 21#engageug
  • 22. Introspecting GraphQL Schema GraphQL schema can be introspected with GraphQL query! • __schema queries the schema • __type introspects a specific type • kind introspects field type • If NON_NULL, ofType returns its actual type “It’s GraphQL queries all the way down” 22#engageug
  • 23. GraphQL – Real World Implementations - Facebook - Watson Works Services - Darwino (OpenSource Project hosted on OpenNTF and darwino.org) - Connections Pink 23#engageug
  • 24. Darwino GraphQL Implementation Darwino is providing a set of open source libraries for both consumers and producers of GraphQL The libraries are part of the Darwino core code but hosted on OpenNTF/darwino.org The code depends on some core Darwino classes (JSON, utilities…) but these are part of Darwino community edition 24#engageug
  • 25. Schemaless GraphQL Queries GraphQL uses static schemas to validate the queries and make them discoverable by tools (code completion…) This forces the queries to be fully defined on the producer side All the fields have to be predefined All the relations between data sets have to be predefined as well What about semi structured data, like Domino documents? -> Would benefit from more flexibility To seamlessly access the data in an unstructured document To make prototyping easier and faster To traverse relations that are not known upfront 25#engageug
  • 26. Dynamic JSON Data Type A JSON data type is a GraphQL type that exposes its content as a virtual JSON Object Its dynamic content is accessed using pseudo fields extract the value using JSON Path 26#engageug
  • 27. A Simple Domino Example Reading items from an existing Domino document DominoDocument is a pseudo field loading a document based on parameters, and returning a JSON data type string is a pseudo field extracting a string value from a JSON data type using a JSON path 27#engageug doc: DominoDocument(database:"DarwinoReports.nsf", unid:"DD2028D6B53ADCCB852581080009C40E") { _unid, code: string(path:"PRODUCTCODE"), name: string(path:"PRODUCTNAME"), } https://playground.darwino.com/playground.nsf/GraphqlSnippets.xsp#snippet=Notes_Domino_Read_Document
  • 28. Dynamic JSON Types Dynamic JSON types are pseudo fields that can be added any object By convention, these fields start with a capital letter, like a class in Java: DominoDocument, DominoView… They are used with an alias to name the result field Dynamic types are contributed by extension points,then added to every type in the final GraphQL schema. 28#engageug view: DominoView(name: “myview”){ … doc: DominoDocument(unid: ‘xxx’) { … } }
  • 29. Dynamic JSON Fields Dynamic fields are also peudo fields, extracting a value using a JSON path and coercing the result to the desired type: New dynamic fields can be added by the developers 29#engageug val: string(path:“a.b.c") val: number(path:“a.b.c") val: int:“a.b.c") val: long(path:“a.b.c") val: boolean(path:“a.b.c") val: value(path:“a.b.c") val: eval(formula:“@Trim(@UserName)")
  • 30. JSON Path Introduction A JSON Path is to JSON what an XPath is to XML The syntax is closed to JavaScript, starting with a ‘$’ $.firstName $.spouse.firstName $.spouse[‘firstName’] $.addresses[1].street $ {whole document} There are more complex operators http://goessner.net/articles/JsonPath/ Darwino core provides a high performance, advanced JSON Path engine 30#engageug { firstName: ‘Barak’, spouse: { firstName: ‘Michele’, … } addresses: [ { street: ‘Main St’, …}, { street: ‘Bob Sq’, …}, ], … }
  • 31. Static Fields A JSON dynamic type can mix and match static fields with dynamic ones By convention, system fields start with a ‘_’ (_unid, …) Functional static fields can be added 31#engageug DominoDocument(database:"DarwinoReports.nsf", unid:"DD2028D6B53ADCCB852581080009C40E") { _unid, _noteId, _created, _lastAccessed, user { cn, dn } name: string(path:"PRODUCTNAME"), }
  • 32. Passing Parameters to JSON Types In the previous Domino example, the unid parameter is hard coded which is not that useful… unid can be set from a GraphQL variable, but this is also global to the request – cannot be used for relations Darwino implementation uses a special syntax to calculate parameters Delegates the evaluation of ‘docid’ to the parent object Drawback: all parameters have to be declared as strings in GraphQL 32#engageug doc: DominoDocument(unid:$VAR) doc: DominoDocument(unid:”${docid}”)
  • 33. Parameters Example 33#engageug doc: CursorDocument(database:"playground", store:"owners") { dn: string(path:"dn"), firstName: string(path:"firstName"), lastName: string(path:"lastName"), pinballs: objectArray(path:"pinballs[*]") { pinball: Document(unid:"${ipdb}",database:"playground", store:"pinball") { name: string(path:"name"), manufacturer: string(path:"manufacturer"), released: number(path:"released"), players: long(path:"players"), flippers: int(path:"flippers") } } } https://playground.darwino.com/playground.nsf/GraphqlSnippets.xsp#snippet=Json_St ore_Document_Document_join_on_Unid
  • 34. Mixing Content Mixing JSON documents with Users coming from LDAP 34#engageug docs: CursorDocuments(database:"playground", store:"owners“) { dn: string(path:"dn"), firstName: string(path:"firstName"), user:User(dn:"${dn}") { dn, cn, email } https://playground.darwino.com/playground.nsf/GraphqlSnippets.xsp#snippet=Mixed _Document_join_on_User_Directory___Unid
  • 35. Java Client Builder • A GraphQL query is a text file that is always painful to build safely • Escaping the text pieces, quotes… • Making sure that all the braces { } are balanced • Format it to be either compacted or developer friendly • Darwino provides an easy to use builder to help the creation of queries in Java • Highly readable by developer • Supports code completion in a Java IDE • Based on the Java Builder pattern • Fully extensible to handle known objects 35#engageug
  • 36. A Simple GraphQL Query 36#engageug query MyQuery { field1 name: field2 field3(p=‘3’) { subfield } } String q = new GQuery("MyQuery") .field("field1") .field(“name", "field2") .field(new GField(field3) { .attribute(“p”,”3”) .field(“subfield") }) .build();
  • 37. Example from the Playground Putting it altogether… 37#engageug String q = new GQuery("example") .field(new GField("Document") .attribute("unid", "1000") .attribute("database", "playground") .attribute("store", "pinball") .field("_id") .field("_unid") .field("_cdate") .field("_muser") .stringField("name","name") .stringField("manufacturer","manufacturer") .numberField("released","released") .longField("players","players") .intField("flippers","flippers") ).build(); https://playground.darwino.com/playground.nsf/JavaSnippets.xsp#snippet=GraphQL_Run_Inline_Client_Query
  • 38. Watson Work Services Java SDK Java SDK for Watson Work Service • On OpenCode4Workspace (run by OpenNTF) • Download the project • Consume from Maven <dependency> <groupId>org.opencode4workspace.watson-work-services</groupId> <artifactId>wws-api</artifactId> <version>0.6.0</version> </dependency> • View source code on Stash (includes Junit tests) • Explore implementation in Watson Workspace for Eclipse / Notes Latest documentation on OpenNTF Wiki, Javadoc available 38#engageug
  • 39. Watson Work Services Java SDK Client authentication as application Client authentication as user Build queries with Java objects, methods and enums • No need to construct queries as complex Strings Methods to output built query as String and response as String Conversion of response to Java objects Methods to parse error responses Standard REST endpoints also supported 39#engageug
  • 40. WWS Java SDK Samples 40#engageug
  • 41. WWS Java SDK Samples 41#engageug
  • 42. WWS Java SDK Variables not current supported • Use Java method to construct query based on variable Fragments not currently supported • Use Java method / object to specify standard fields Directives not currently supported • Use Java method to construct query based on variable Aliases not currently supported • Track the JIRA issue 42#engageug
  • 43. Resources GraphQL website, http://graphql.org GraphQL community resources, http://graphql.org/community/ GraphQL Visualization Tool, http://nathanrandal.com/graphql- visualizer/ WWS developer documentation, https://workspace.ibm.com/developer/docs WWS GraphiQL IDE, https://workspace.ibm.com/graphql WWS API Java SDK, https://openntf.org/main.nsf/project.xsp?r=project/Watson%20 Work%20Services%20Java%20SDK 43#engageug
  • 44. Thank You 44#engageug Paul Withers Intec Systems Ltd & OpenNTF pwithers@intec.co.uk @paulswithers https://www.intec.co.uk/blog https://paulswithers.github.io Philippe Riand Darwino Inc. phil@darwino.com @philriand http://blog.riand.com/ https://www.darwino.com/