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

451 行
13KB

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