-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
410 lines (339 loc) · 14.3 KB
/
Copy pathindex.html
File metadata and controls
410 lines (339 loc) · 14.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GraphQL with Sangria</title>
<meta name="description" content="A framework for easily creating beautiful presentations using HTML">
<meta name="author" content="Thanh Tu">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/white.css" id="theme">
<link rel="stylesheet" href="assets/custom.css">
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<script src="assets/offline/fonts.js"></script>
<script src="https://use.typekit.net/jor2kyz.js"></script>
<script>try{Typekit.load({ async: true });}catch(e){}</script>
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
<link rel="stylesheet" href="assets/highlight/solarized_light.css">
<link href="//cdn.jsdelivr.net/graphiql/0.4.2/graphiql.css" rel="stylesheet" />
</head>
<body>
<div id="credit" style="display: none"></div>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section data-background="linear-gradient(45deg, #3A5999 0%, rgba(0,248,255,0.75) 100%)" class="first-slide">
<img src="assets/img/graphql-white.svg" class="logo-image"/>
<p style="text-align: center" class="title-font">
Introduction to <strong>GraphQL</strong>
</p>
<p style="font-size: 70%; opacity: 0.5" class="normal-font">
by Thanh Tu / <a href="#">tu@agiletech.vn</a>
</p>
</section>
<section>
<h2>Typical Rest API</h2>
<img src="assets/img/rest-api.svg" style="width: 80%">
</section>
<section>
<h2>Common Issues</h2>
<ul>
<li>
Over-fetching
<ul class="fragment fade-in" data-fragment-index="1">
<li>/products?<span class="qname">field</span>=<span class="qvalue">name</span>&<span class="qname">field</span>=<span class="qvalue">description</span>&<span class="qname">field</span>=<span class="qvalue">variants[*].price</span></li>
</ul>
</li>
<li class="fragment fade-in" data-fragment-index="2">
Under-fetching
<ul class="fragment fade-in" data-fragment-index="3">
<li>/products?<span class="qname">expand</span>=<span class="qvalue">productType</span>&<span class="qname">expand</span>=<span class="qvalue">variants[*].price.taxRate</span></li>
</ul>
</li>
<li class="fragment fade-in" data-fragment-index="4">
API changes and evolution
<ul class="fragment fade-in" data-fragment-index="5">
<li>Versioning</li>
<li>Deprecation</li>
<li>Maintenance</li>
</ul>
</li>
</ul>
</section>
<section>
<h2>API Gateways</h2>
<img src="assets/img/api-gateway.svg">
</section>
<section>
<h2>GraphQL Approach</h2>
<img src="assets/img/graphql-api.svg" style="max-width: 70%">
</section>
<section>
<h2>GraphQL</h2>
<ul>
<li>A data query language</li>
<li class="fragment fade-in" data-fragment-index="1">Developed by Facebook</li>
<li class="fragment fade-in" data-fragment-index="2">Used internally since 2012</li>
<li class="fragment fade-in" data-fragment-index="3">Open source version published in July 2015</li>
<li class="fragment fade-in" data-fragment-index="4">Relay released in August 2015</li>
<li class="fragment fade-in" data-fragment-index="5">Specification: <a href="https://facebook.github.io/graphql" target="_blank">https://facebook.github.io/graphql</a></li>
</ul>
</section>
<section>
<h2>Response Structure</h2>
<pre style="float: left; width: 50%"><code data-trim contenteditable class="javascript">
query MyProduct {
product(id: 123) {
name
description
picture {
width
height
url
}
}
}
</code></pre>
<pre style="float: left; width: 50%" class="fragment fade-in" data-fragment-index="1"><code data-trim contenteditable class="javascript">
{
"data": {
"product": {
"name": "Delicious Cake",
"description": "Just taste it!"
"picture": {
"width": 150,
"height": 150,
"url": "http://..."
}
}
}
}
</code></pre>
</section>
<section>
<h2>Every field Is a Function</h2>
<pre style="float: left; width: 50%"><code data-trim contenteditable class="javascript">
query MyProduct {
products {
picture(size: 300) {
width, height, url
}
}
}
</code></pre>
<pre style="float: left; width: 50%" class="fragment fade-in" data-fragment-index="1"><code data-trim contenteditable class="javascript">
{
"data": {
"products": [
{
"picture": {
"width": 300,
"height": 300,
"url": "http://..."
}
},
...
]
}
}
</code></pre>
</section>
<section>
<h2>Aliases</h2>
<pre style="float: left; width: 50%"><code data-trim contenteditable class="javascript">
query MyProduct {
products {
thumb: picture(size: 100) {
width
}
fullSize: picture(size: 500) {
width
}
}
}
</code></pre>
<pre style="float: left; width: 50%" class="fragment fade-in" data-fragment-index="1"><code data-trim contenteditable class="javascript">
{
"data": {
"products": [
{
"thumb": {
"width": 100
},
"fullSize": {
"width": 500
}
},
...
]
}
}
</code></pre>
</section>
<section>
<img src="assets/img/data-requirements.svg">
</section>
<section>
<h2>Type System</h2>
<pre style="float: left; width: 60%"><code data-trim contenteditable class="javascript">
type Picture {
width: Int!
height: Int!
url: String
}
</code></pre>
<pre style="float: left; width: 40%" class="fragment fade-in" data-fragment-index="3"><code data-trim contenteditable class="javascript">
type Query {
product(id: Int!): Product
products: [Product]
}
</code></pre>
<pre style="float: left; width: 60%" class="fragment fade-in" data-fragment-index="1"><code data-trim contenteditable class="javascript">
interface Identifiable {
id: String!
}
</code></pre>
<pre style="float: left; width: 60%" class="fragment fade-in" data-fragment-index="2"><code data-trim contenteditable class="javascript">
type Product implements Identifiable {
id: String!
name: String!
description: String
picture(size: Int): Picture
}
</code></pre>
</section>
<section>
<h2>Mutations & Subscriptions</h2>
<pre><code data-trim contenteditable class="javascript">
mutation ChangeStaff {
changeName(productId: 123, newName: "Cheesecake") {
id, version
}
setDescription(productId: 123, description: "Delicious!") {
id, version
}
}
subscription ProductEvents {
nameChanged(productId: 123) { name }
productDeleted { id }
}
</code></pre>
</section>
<section>
<h2>Demo Time</h2>
<!-- GrpahiQL, Fragments, Introspection, docs -->
<a href="https://github.com/agiletechvn/ReactNativeGraphql">https://github.com/agiletechvn/ReactNativeGraphql</a>
<img src="https://github.com/agiletechvn/ReactNativeGraphql/raw/master/graphql_subscription.png"/>
</section>
<section>
<h2>Backend Agnostic</h2>
<img src="assets/img/app-layers.svg" style="width: 75%">
</section>
<section>
<h2>Languages</h2>
<div class="logos">
<div class="impl-logo"><a href="https://github.com/graphql/graphql-js/"><img src="assets/img/js-logo.svg"></a></div>
<div class="impl-logo"><a href="https://github.com/graphql/graphql-js/"><img src="assets/img/node-logo.svg"></a></div>
<div class="impl-logo fragment fade-in" data-fragment-index="1"><a href="http://sangria-graphql.org/"><img src="assets/img/scala-logo.svg"></a></div>
<div class="impl-logo fragment fade-in" data-fragment-index="1"><a href="http://sangria-graphql.org/"><img src="assets/img/sangria-logo.svg"></a></div>
<div class="impl-logo fragment fade-in" data-fragment-index="2"><a href="https://github.com/graphql-java/graphql-java"><img src="assets/img/java-logo.svg"></a></div>
<div class="impl-logo fragment fade-in" data-fragment-index="3"><a href="http://graphene-python.org/"><img src="assets/img/python-logo.svg"></a></div>
<div class="impl-logo fragment fade-in" data-fragment-index="3"><a href="http://graphene-python.org/"><img src="assets/img/graphene.png"></a></div>
<div class="impl-logo fragment fade-in" data-fragment-index="4"><a href="https://github.com/rmosolgo/graphql-ruby"><img src="assets/img/ruby_logo.svg"></a></div>
<div class="impl-logo fragment fade-in" data-fragment-index="5"><a href="https://github.com/graphql-elixir/graphql"><img src="assets/img/elixir-logo.png" ></a></div>
<div class="impl-logo fragment fade-in" data-fragment-index="6"><a href="https://github.com/jdnavarro/graphql-haskell"><img src="assets/img/haskell-logo.svg"></a></div>
<div class="impl-logo fragment fade-in" data-fragment-index="6"><a href="https://github.com/graphql-go/graphql"><img src="assets/img/gopher.svg"></a></div>
<div class="impl-logo fragment fade-in" data-fragment-index="6"><a href="https://github.com/bjornbytes/graphql-lua"><img src="assets/img/lua-logo.svg"></a></div>
<div class="impl-logo fragment fade-in" data-fragment-index="6"><a href="https://github.com/webonyx/graphql-php"><img src="assets/img/php_logo.png"></a></div>
<div class="impl-logo fragment fade-in" data-fragment-index="6"><a href="https://github.com/graphql/libgraphqlparser"><img src="assets/img/c-logo.svg"></a></div>
<div class="impl-logo fragment fade-in" data-fragment-index="6"><a href="https://github.com/graphql-dotnet/graphql-dotnet"><img src="assets/img/csharp-logo.png"></a></div>
</div>
</section>
<section>
<h2>Example: JavaScript</h2>
<pre><code data-trim contenteditable class="javascript">
var ProductType = new GraphQLObjectType({
name: "Product",
description: "Commodity available for purchase",
fields: {
id: {type: GraphQLString},
onStock: {
type: GraphQLInt,
resolve(product) {
return product.onStock + 10;
}
}
}
});
</code></pre>
</section>
<section>
<h2>Example: Scala</h2>
<pre><code data-trim contenteditable class="scala">
val ProductType = ObjectType(
"Product",
"Commodity available for purchase",
fields[Unit, Product](
Field("id", StringType,
resolve = _.value.id),
Field("onStock", IntType,
resolve = _.value.onStock + 10)))
</code></pre>
<pre class="fragment roll-in" data-fragment-index="1"><code data-trim contenteditable class="scala">
val ProductType = deriveObjectType[Unit, Product]()
</code></pre>
</section>
<section data-background="linear-gradient(45deg, #3A5999 0%, rgba(0,248,255,0.75) 100%)" class="first-slide">
<h1>Thank you!</h1>
<br>
<ul class="fragment roll-in" data-fragment-index="2">
<li><a href="http://bit.ly/graphql-introduction" target="_blank">http://bit.ly/graphql-introduction</a></li>
<li><strong>GraphQL:</strong> <a href="http://graphql.org" target="_blank">http://graphql.org</a></li>
<li><strong>Twitter:</strong> <a href="https://twitter.com/easyangel" target="_blank">https://twitter.com/easyangel</a></li>
<li><strong>Zero To GraphQL:</strong> <a href="http://bit.ly/zero-to-graphql" target="_blank">http://bit.ly/zero-to-graphql</a></li>
<li><strong>Sangria Playground:</strong> <a href="http://try.sangria-graphql.org" target="_blank">http://try.sangria-graphql.org</a></li>
</ul>
<br><br>
<h2 class="fragment roll-in" data-fragment-index="3" style="opacity: 0.7;">Questions?</h2>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script src="assets/jquery-2.1.3.min.js"></script>
<script src="assets/custom.js"></script>
<script>
// Full list of configuration options available at:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, condition: function() { return !!document.querySelector( 'pre code' ); }, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true },
{ src: 'plugin/notes/notes.js', async: true }
]
});
</script>
</body>
</html>