10. To exec your 1st GraphQL query
De ne Data Types
De ne Query Types
De ne Schema
Execute queries against the de ned schema
5 . 2
11. De ne Data Types
type Contestant {
name: String
}
type Raffle {
id: String
title: String
contestants: [Contestant]
noWinners: Int
}
http://facebook.github.io/graphql/
5 . 3
12. De ne Queries
Query is just another type
It de nes all possible queries over de ned types
Queries can use other types or scalars
Queries may have arguments
type Query {
list: [Raffle]
getWinners(raffleId: String!): [Contestant]
}
5 . 4
13. De ne Schema
Which is the type for queries
Which is the type for mutations
type schema {
query: Query
mutation: Mutation
}
5 . 5
14. Execute a query
query: "give me (id, title) of all raf es
result: list of available raf es
{
list {
id
title
}
}
{
"data": {
"list": [
{
"id": "pfoqjfq09w8jf",
"title": "A Greach T-Shirt"
}
]
}
}
5 . 6
15. Validation
raf eId was mandatory
Invalid query
type Query {
...
winners(raffleId: String!): [Contestant]
...
}
{
winners {
name
}
}
5 . 7
28. Faster interaction w Front End
Queries and Mutations can be batched
Queries are executed in parallel
No more controllers / handlers
GraphQL engine takes care of input formal validation
6 . 7
31. Why Ratpack ?
Is lightweight
It is a lean and powerful foundation, not an all-
encompassing framework.
Very good performance
Netty + Ratpack’s execution model
6 . 10
32. Exposing GraphQL with Ratpack
gql-ratpack
Module of GQL project
It provides:
GraphQL endpoint
G hiQ l
https://grooviter.github.io/gql/docs/html5/index.html#_ratpack
6 . 11
39. Honor Ratpack's executors
CompletableFuture can be used as a service return type
Access executors via ratpack.exec.Execution
Execute CompletableFuture using the proper executor
Create your own abstractions
7 . 4
53. Security
Did I mention that GraphQL is a query language ?
It knows nothing about security mechanisms
We have to make the engine aware of security…
Using the Context
9 . 2
54. Context
Can carry information from outside to the GraphQL
execution ow
Can be any type of data structure (Map, List…)
Available through all the execution ow (instrumentations
and data fetchers)
9 . 3
64. Alternatives to Ratpack + GQL
gorm-graphql with/without Grails, Micronaut…
If you like GORM, and ts your plan, use it!
graphql-java
DIY
https://github.com/grails/gorm-graphql
h // h l j d h d i / /l / 10 . 5
66. Summary: GraphQL
Is not a silver bullet
Is an improvement between back/front
GraphQL It’s not limited to HTTP
As a query language, is still underestimated
11 . 2