-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphQL.html
More file actions
390 lines (349 loc) · 12.4 KB
/
GraphQL.html
File metadata and controls
390 lines (349 loc) · 12.4 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GraphQL</title>
<meta name="author" content="Petr Šnobelt">
<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">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.6.0/css/reveal.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.6.0/css/theme/night.css" id="theme">
<link rel="shortcut icon" href="http://graphql.org/img/favicon.png" />
<!-- If the query includes 'print-pdf', use the PDF print sheet -->
<script>
document.write('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.6.0/css/print/' + (window.location.search.match(/print-pdf/gi) ? 'pdf' : 'paper') + '.css" type="text/css" media="print">');
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section data-background-image="http://graphql.org/img/logo.svg" data-background-size="70%">
</section>
<section>
<h1>GraphQL</h1>
<blockquote>
<small>
GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides
a complete and understandable description of the data in your API, gives clients the power to ask for exactly what
they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools.
</small>
</blockquote>
<p>
<small>
<a href="mailto:petr.snobelt@gmail.com">Petr Šnobelt</a> /
<a href="http://twitter.com/petrsnobelt">@petrsnobelt</a>
</small>
</p>
</section>
<section>
<h2>Agenda</h2>
<ul>
<li>GraphQL introduction</li>
<li>Ipex journey</li>
<li>Samples</li>
<li>Advanced features</li>
<li>Discussion</li>
</ul>
</section>
<section>
<h2>GraphQL facts</h2>
<ul>
<li>Developed internally by Facebook in 2012</li>
<li>Initial public release in 2015</li>
<li>Opensource</li>
<li>current release 0.12.3 (Dec 17, 2017)</li>
<li>
<a href='https://github.com/graphql/graphql-js'>https://github.com/graphql/graphql-js</a>
</li>
</ul>
<aside class="notes">
Note Netflix/falcor.
</aside>
</section>
<section>
<section>
<h3>Základní charakteristika</h3>
<ul>
<li>NewAge API 😀</li>
<li>StrongTyped</li>
<li>DB/Data source independent</li>
<li>GraphQL servers are available for all major languages</li>
</ul>
</section>
<section>
<h3>Allows clients to dictate what data is needed</h3>
</section>
</section>
<section>
<section>
<h3>RestAPI problems</h3>
<ol>
<li>multiple requests</li>
<li>overfetching</li>
<li>documentation</li>
<li>realtime (websockets)</li>
</ol>
</section>
<section>
<h3>#1 multiple requests</h3>
<p>Je možné skládat více dotazů do jednoho</p>
<p>Je možné se zeptat na objednávku, její řádky i odběratele najednou<p>
</section>
<section>
<h3>#2 overfetching</h3>
<p>Klient si může vybrat které data chce</p>
</section>
<section>
<h3>#3 documentation</h3>
<p>
Api je dokumentované pomocí typů a komentářů
</p>
<p>Protože si klient vybírá, jaké data chce není tak velká potřeba api verzovat</p>
</section>
<section>
<h3>#4 realtime
<br /> subscriptions
</h3>
<p>
Je možné se přihlásit k odběru dat pomocí websockets
</p>
</section>
</section>
<section>
<h3>Firmy využívající graphQL</h3>
<ul>
<li>Twitter, GitHub, Facebook, Ipex 😎</li>
<li>
<a href='http://graphql.org/users/'>reference na webu</a>
</li>
</ul>
</section>
<section>
<h2>IPEX way to graphQL</h2>
<ol>
<li class="fragment">Internal workshop</li>
<li class="fragment">Basic skeleton tested using GraphiQL</li>
<li class="fragment">Subscriptions</li>
<li class="fragment">Use storybook for components</li>
<li class="fragment">Win 😄</li>
</ol>
<aside class="notes">
<ul>
<li>
Internal workshop - graphql or native rethingdb client
<ul>
<li>We like graphql</li>
<li>Rethinkdb future is hmm…</li>
</ul>
</li>
<li>
Create basic skeleton of first functions
<ul>
<li>Velký důraz na mutace</li>
<li>Different clients to different instances</li>
<li>Try graphql in graphiql</li>
<li>It helps backend developers try what they do</li>
</ul>
</li>
<li>
Subscriptions
<ul>
<li>Not much used, but critical for us</li>
<li>2 options
<ul>
<li>Notify “data is changed only”
<ul>
<li>Simple but “slower” and can cause trouble for backend for too many requests</li>
</ul>
</li>
<li>Send data with mutations
<ul>
<li>No guaidance, so we build our own system</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>
Use storybook for components
<ul>
<li>Help iterate quickly</li>
<li>Split to container and graphql components
<ul>
<li>While backend is not ready programmers can create components and know which data components needed</li>
</ul>
</li>
<li>Also non-programers can see components and it’s variants</li>
<li>We have requirment to use “CC Panels” separately, and storybook helps</li>
</ul>
</li>
</ul>
</aside>
</section>
<section>
<section>
<h3>Live coding, samples</h3>
<h2>Server</h2>
<ul>
<li class="fragment grow visible">Basic query and mutation</li>
<li class="fragment grow visible">More query samples</li>
<li class="fragment grow visible">Add subscription</li>
</ul>
</section>
<section>
<h3>Live coding, samples</h3>
<h2>Client</h2>
<ul>
<li class="fragment grow visible">Basic react component</li>
<li class="fragment grow visible">React component with subscription</li>
<li class="fragment grow visible">Show end result</li>
<li class="fragment grow visible">devtools</li>
</ul>
</section>
<aside class="notes">
Basic query and mutation
- add filter and it can be custom
- add new query
- add basic mutation
Add subscription
- add packages
- add server
- modify schema
Prepare showing of endresult
</aside>
</section>
<section>
<section>
<h2>Our Troubles</h2>
<ul>
<li class="fragment">Caching</li>
<li class="fragment">Authorizations</li>
<li class="fragment">Apollo client internals
<ul>
<li>Data “normalization”</li>
<li>Set correct keys</li>
</ul>
</li>
<li class="fragment">Subscriptions monitoring
<ul>
<li>
<a href='https://www.npmjs.com/package/debug'>Debug</a> library helps</li>
</ul>
</li>
</ul>
</section>
<section>
<h2>Problémy graphQL</h2>
<ul>
<li>relativně "mladá" technologie</li>
<li>problémy(nevyužití) s http cachováním<br />
(používá POST)</li>
<li><strong>Query N+1 problém </strong> <br>
řešením je <a href='https://github.com/facebook/dataloader'>dataloader</a></li>
<li>LoadBalancing subscriptions <br>
stejné jako u websocketů
</li>
</ul>
</section>
</section>
<section>
<h2>Hidden features</h2>
<ul>
<li>Different schemas</li>
<li>Input validation</li>
<li>Declarativní zápis jaké data komponenta potřebuje</li>
<li>
<strong>“Remove complexity while building frontend clients”</strong>
</li>
</ul>
</section>
<section>
<h3>Advanced features of</h3>
<h2>Apollo <del>client</del> 2.0</h2>
<ul>
<li>Query rest, compose requests</li>
<li><a href='https://github.com/apollographql/apollo-link-state'>Client-side state management</a></li>
<li>Combine local and server data in one query</li>
<li>apollo cache persist</li>
</ul>
</section>
<section>
<h2>Sample of advanced features</h2>
<p>If time permits</p>
<ul>
<li>Using graphQL for rest</li>
<li>Using graphql for local storage</li>
<li>Custom resolvers</li>
</ul>
</section>
<section>
<h3>Stojí to za to?</h3>
<ul>
<li>as always - it depend on project</li>
<li>in our case yes</li>
<li>...but you should try it</li>
</ul>
</section>
<section>
<section>
<h3>Resources I/II</h3>
<h4>Articles</h4>
<ul>
<li><a href='https://dev-blog.apollodata.com/2017-the-year-in-graphql-124a050d04c6'>2017: The year in GraphQL</a></li>
<li><a href='https://dev-blog.apollodata.com/the-future-of-state-management-dd410864cae2'>The future of state management</a></li>
<li><a href='https://dev-blog.apollodata.com/apollo-client-2-0-beyond-graphql-apis-888807b53afe'>Apollo Client 2.0: Beyond GraphQL APIs</a></li>
<li><a href='https://dev-blog.apollodata.com/whats-next-for-react-apollo-4d41ba12c2cb'>What’s next for React Apollo</a>
(Query components)</li>
<li><a href='https://www.youtube.com/channel/UC0pEW_GOrMJ23l8QcrGdKSw/videos'>Apollo GraphQL</a></li>
</ul>
</section>
<section>
<h3>Resources II/II</h3>
<h4>Tools</h4>
<ul>
<li><a href='https://github.com/graphql/graphiql'>Graph<em>i</em>QL</a></li>
<li><a href='https://altair.sirmuel.design'>Altair GraphQL Client</a></li>
<li>Apollo client, <a href='https://github.com/apollographql/apollo-client-devtools'>Apollo client devtools</a></li>
<li>Redux dev tools</li>
<li><a href='https://github.com/postgraphql/postgraphql'>postgraphql</a></li>
<li><a href='https://www.prismagraphql.com'>Prisma</a> <small>turns your database into a realtime GraphQL API</small></li>
</ul>
</section>
</section>
<section>
<h2>Děkuji za pozornost</h2>
<p>Otázky?</p>
<br />
<h4>Petr Šnobelt
<br /> petr.snobelt@gmail.com
<br /> @petrsnobelt</h4>
</section>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.6.0/lib/js/head.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.6.0/js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'concave', // default/cube/page/concave/zoom/linear/fade/none
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.6.0/lib/js/classList.js', condition: function () { return !document.body.classList; } },
{ src: 'https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.6.0/plugin/markdown/marked.js', condition: function () { return !!document.querySelector('[data-markdown]'); } },
{ src: 'https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.6.0/plugin/markdown/markdown.js', condition: function () { return !!document.querySelector('[data-markdown]'); } },
{ src: 'https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.6.0/plugin/highlight/highlight.js', async: true, callback: function () { hljs.initHighlightingOnLoad(); } },
{ src: 'https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.6.0/plugin/zoom-js/zoom.js', async: true, condition: function () { return !!document.body.classList; } },
{ src: 'https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.6.0/plugin/notes/notes.js', async: true, condition: function () { return !!document.body.classList; } }
]
});
</script>
</body>
</html>