您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

422 行
12KB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta
  6. name="viewport"
  7. content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
  8. />
  9. <title>Graphql</title>
  10. <link rel="stylesheet" href="dist/reset.css" />
  11. <link rel="stylesheet" href="dist/reveal.css" />
  12. <link rel="stylesheet" href="dist/theme/black.css" id="theme" />
  13. <!-- Theme used for syntax highlighted code -->
  14. <link
  15. rel="stylesheet"
  16. href="plugin/highlight/monokai.css"
  17. id="highlight-theme"
  18. />
  19. </head>
  20. <body>
  21. <div class="reveal">
  22. <div class="slides">
  23. <section>
  24. <section>
  25. <img
  26. src="/assets/graphql.png"
  27. alt="graphql logo"
  28. style="
  29. height: 180px;
  30. margin: 0 auto 4rem auto;
  31. background: transparent;
  32. "
  33. class="demo-logo"
  34. />
  35. <h1>Graphql</h1>
  36. <p>Open-Source</p>
  37. <p>Released 2015 from Facebook</p>
  38. </section>
  39. </section>
  40. <section>
  41. <section>
  42. <h1>Whats Graphql?</h1>
  43. <p>and how it differs from REST?</p>
  44. </section>
  45. <section>
  46. <h2>🍕 Pizza service</h2>
  47. </section>
  48. <section class="scrollable-slide">
  49. <img
  50. src="/assets/restful-architecture.png"
  51. alt="rest-architecture"
  52. style="background: transparent"
  53. class="demo-logo fit-picture"
  54. />
  55. </section>
  56. <section class="scrollable-slide">
  57. <img
  58. src="/assets/graphql-architecture.png"
  59. alt="graphql-architecture"
  60. style="background: transparent"
  61. class="demo-logo fit-picture"
  62. />
  63. </section>
  64. <section>
  65. <h3>Rest Service</h3>
  66. <img
  67. src="/assets/pizza-rest.png"
  68. alt="rest graph"
  69. style="background: transparent"
  70. class="demo-logo fit-picture"
  71. />
  72. </section>
  73. <section>
  74. <h3>Graphql Service</h3>
  75. <img
  76. src="/assets/pizza-graphql.png"
  77. alt="Graphql graph"
  78. style="background: transparent"
  79. class="demo-logo fit-picture"
  80. />
  81. </section>
  82. </section>
  83. <section>
  84. <section>
  85. <h1>Basics</h1>
  86. </section>
  87. <section>
  88. <ul>
  89. <li>Types</li>
  90. <li>Querys</li>
  91. <li>Mutations</li>
  92. <li>Subscriptions</li>
  93. <li>Variables</li>
  94. </ul>
  95. </section>
  96. <section>
  97. <h2>Types</h2>
  98. <pre><code data-trim data-noescape>
  99. type Pizza {
  100. id: ID!
  101. name: String!
  102. toppings: [Topping!]!
  103. }
  104. type Topping {
  105. id: ID!
  106. name: String!
  107. }
  108. </code>
  109. </pre>
  110. </section>
  111. <section>
  112. <h2>Querys</h2>
  113. <h4>Define Querys</h4>
  114. <pre>
  115. <code data-trim data-noescape>
  116. type Query {
  117. getPizzaById(pizzaId: ID!): Pizza!
  118. getToppingById(toppingId: ID!): Topping!
  119. getPizzaByName(pizzaName: ID!): Pizza!
  120. getToppingByName(toppingName: ID!): Topping!
  121. listPizza: [Pizza]!
  122. listTopping: [Topping]!
  123. }
  124. </code>
  125. </pre>
  126. </section>
  127. <section>
  128. <h2>Querys</h2>
  129. <pre><code data-trim data-noescape>
  130. {
  131. listPizza {
  132. id
  133. name
  134. }
  135. }
  136. </code>
  137. </pre>
  138. </section>
  139. <section>
  140. <h2>Querys</h2>
  141. <pre>
  142. <code data-trim data-noescape>
  143. {
  144. getPizzaById(pizzaId: "0") {
  145. id
  146. name
  147. toppings {
  148. name
  149. }
  150. }
  151. }
  152. </code>
  153. </pre>
  154. </section>
  155. <section>
  156. <h2>Mutations</h2>
  157. <h4>Define Mutations</h4>
  158. <pre><code data-trim data-noescape>
  159. type Mutation {
  160. createPizza(createPizzaDto: ChangePizzaDto): Pizza!
  161. updatePizza(pizzaId: ID!, updatedPizzaDto: ChangePizzaDto!): Pizza!
  162. createTopping(createToppingDto: ChangeToppingDto): Topping!
  163. updateTopping(toppingId: ID!, updatedToppingDto: ChangeToppingDto!): Topping!
  164. }
  165. </code>
  166. </pre>
  167. </section>
  168. <section>
  169. <h2>Mutations</h2>
  170. <pre>
  171. <code data-trim data-noescape>
  172. mutation {
  173. createPizza (createPizzaDto: {
  174. name: "My Awesome Pizza"
  175. toppingIds: "1"
  176. }) {
  177. id
  178. name
  179. toppings {
  180. id
  181. name
  182. }
  183. }
  184. }
  185. </code>
  186. </pre>
  187. </section>
  188. <section>
  189. <h2>Subscriptions</h2>
  190. <h4>Define Subscription</h4>
  191. <pre>
  192. <code data-trim data-noescape>
  193. type Subscription {
  194. pizzasChanged: [Pizza]!
  195. toppingsChanged: [Topping]!
  196. }
  197. </code>
  198. </pre>
  199. </section>
  200. <section>
  201. <h2>Subscriptions</h2>
  202. <pre>
  203. <code data-trim data-noescape>
  204. subscription PizzaChanged {
  205. pizzasChanged {
  206. id
  207. name
  208. }
  209. }
  210. </code>
  211. </pre>
  212. </section>
  213. </section>
  214. <section>
  215. <section>
  216. <h1>benefits</h1>
  217. </section>
  218. <section>
  219. <h2>No more Over- and Underfetching</h2>
  220. fixed data structures provide to much or not enough data
  221. </section>
  222. <section>
  223. <h2>Type/Schema System</h2>
  224. <ul>
  225. <li>Graphql uses an strict Type and Schema</li>
  226. <li>The Client can be sure about what it get</li>
  227. <li>aswell as the server</li>
  228. </ul>
  229. </section>
  230. <section>
  231. <h2>Growing Community and Integrations</h2>
  232. <ul>
  233. <li>
  234. Good Client side Integrations Angular/React/VueJs and more.
  235. </li>
  236. <li>Server side Integrations in Typescript/Java and more.</li>
  237. <li>Well working code-generator for client and server</li>
  238. <li>Alot of well writen Documentation</li>
  239. </ul>
  240. </section>
  241. <section>
  242. <h2>Self Documenting</h2>
  243. <img
  244. src="/assets/self-doku.png"
  245. alt="self-doku example"
  246. style="background: transparent"
  247. class="demo-logo fit-picture"
  248. />
  249. </section>
  250. <section>
  251. <h2>Faster API Development</h2>
  252. </section>
  253. <section class="scrollable-slide">
  254. <h2>pros/cons</h2>
  255. <a
  256. style="font-size: 14px"
  257. href="https://www.altexsoft.com/blog/engineering/graphql-core-features-architecture-pros-and-cons/"
  258. >
  259. <img
  260. src="/assets/pros-cons.png"
  261. alt="pros-cons"
  262. style="background: transparent"
  263. class="demo-logo fit-picture"
  264. />
  265. </a>
  266. </section>
  267. </section>
  268. <section>
  269. <section>
  270. <h1>Live Demo</h1>
  271. <img
  272. src="/assets/pv.gif"
  273. alt="look at this graphh meme"
  274. style="background: transparent"
  275. class="demo-logo"
  276. />
  277. </section>
  278. <section>
  279. <img
  280. src="/assets/apollo-logo.png"
  281. alt="apollo logo"
  282. style="background: transparent"
  283. class="demo-logo"
  284. />
  285. <p>graphql-codegen</p>
  286. <p>apollo-angular</p>
  287. </section>
  288. <section>
  289. <h2>Requirements</h2>
  290. <ul>
  291. <li>npm</li>
  292. <li>nodejs</li>
  293. <li>tsc</li>
  294. <li>npx</li>
  295. <li>git</li>
  296. </ul>
  297. </section>
  298. <section>
  299. <h2>Setup Server</h2>
  300. </section>
  301. <section>
  302. <h3>Init nodejs</h3>
  303. <pre>
  304. <code data-trim data-noescape>
  305. $ mkdir server && cd server
  306. $ npm init
  307. # entry point: build/index.js
  308. $ npx tsc --init --rootDir src --outDir build \
  309. --esModuleInterop --resolveJsonModule --lib es6 \
  310. --module commonjs --allowJs true --noImplicitAny true
  311. $ npm i --save-dev uuid @types/uuid nodemon ts-node typescript
  312. </code>
  313. </pre>
  314. </section>
  315. <section>
  316. <h3>Create nodemon</h3>
  317. <pre>
  318. <code data-trim data-noescape>
  319. $ touch nodemon.json
  320. </code>
  321. <code data-trim data-noescape>
  322. {
  323. "watch": ["src"],
  324. "ext": ".ts,.js",
  325. "ignore": [],
  326. "exec": "ts-node ./src/index.ts"
  327. }
  328. </code>
  329. </pre>
  330. </section>
  331. <section>
  332. <h3>add script commands to package.json</h3>
  333. <pre>
  334. <code data-trim data-noescape>
  335. "scripts": {
  336. "prebuild": "npm run generate",
  337. "prestart": "npm run generate",
  338. "generate": "graphql-codegen --config codegen.yml",
  339. "start": "nodemon",
  340. "build": "rimraf ./build && tsc"
  341. }
  342. </code>
  343. </pre>
  344. </section>
  345. <section>
  346. <h3>Init graphql</h3>
  347. <pre>
  348. <code data-trim data-noescape>
  349. $ npm add --save-dev graphql
  350. $ npm add --save-dev @graphql-codegen/cli
  351. $ npm add --save-dev @graphql-codegen/typescript
  352. $ npm add apollo-server
  353. $ npm i --save-dev apollo-link-ws
  354. $ npx graphql-codegen init
  355. # (x) Backend
  356. # schema: ./src/schema/*.ts
  357. # plugins:
  358. ◉ TypeScript (required by other typescript plugins)
  359. ◉ TypeScript Resolvers (strongly typed resolve functions)
  360. # output: skip
  361. # introspection: n
  362. # config: skip
  363. # script: generate
  364. $ npm i
  365. $ mkdir src && touch src/index.ts
  366. </code>
  367. </pre>
  368. </section>
  369. <section>
  370. <h2>Setup Frontend</h2>
  371. </section>
  372. <section>
  373. <h3>Init Project</h3>
  374. <pre>
  375. <code data-trim data-noescape>
  376. $ git clone git@ziermach.de:cziermann/angular-demo-template.git
  377. $ git checkout graphql-template
  378. or
  379. $ cd angular-demo-template
  380. $ npm add apollo-angular
  381. $ ng add apollo-angular
  382. $ npm add graphql
  383. $ npm add --save-dev @graphql-codegen/cli
  384. $ npm i
  385. $ npx graphql-codegen init
  386. # with Angular
  387. # skip all
  388. # script: generate
  389. $ npm i
  390. </code>
  391. move the graphql.module.ts in src/
  392. </pre>
  393. </section>
  394. </section>
  395. </div>
  396. </div>
  397. <script src="dist/reveal.js"></script>
  398. <script src="plugin/notes/notes.js"></script>
  399. <script src="plugin/markdown/markdown.js"></script>
  400. <script src="plugin/highlight/highlight.js"></script>
  401. <script>
  402. // More info about initialization & config:
  403. // - https://revealjs.com/initialization/
  404. // - https://revealjs.com/config/
  405. Reveal.initialize({
  406. hash: true,
  407. // Learn about plugins: https://revealjs.com/plugins/
  408. plugins: [RevealMarkdown, RevealHighlight, RevealNotes],
  409. });
  410. </script>
  411. </body>
  412. </html>