3 6 2018 spectacle presentation
play

3/6/2018 Spectacle Presentation @ chrisbiscar di P ARALLELIZING - PDF document

3/6/2018 Spectacle Presentation @ chrisbiscar di P ARALLELIZING PR ODUC T DEVEL OPMENT WITH GRAPHQL http://localhost:3000/#/6?export 1/48 3/6/2018 Spectacle Presentation CHRISBISC ARDI hone y comb . io coff ee @ chrisbiscar di


  1. 3/6/2018 Spectacle Presentation @ chrisbiscar di P ARALLELIZING PR ODUC T DEVEL OPMENT WITH GRAPHQL http://localhost:3000/#/6?export 1/48

  2. 3/6/2018 Spectacle Presentation � CHRISBISC ARDI hone y comb . io coff ee @ chrisbiscar di biscar ch http://localhost:3000/#/6?export 2/48

  3. 3/6/2018 Spectacle Presentation APPLIC A TION AR CHITE C TURE http://localhost:3000/#/6?export 3/48

  4. 3/6/2018 Spectacle Presentation http://localhost:3000/#/6?export 4/48

  5. 3/6/2018 Spectacle Presentation http://localhost:3000/#/6?export 5/48

  6. 3/6/2018 Spectacle Presentation http://localhost:3000/#/6?export 6/48

  7. 3/6/2018 Spectacle Presentation http://localhost:3000/#/6?export 7/48

  8. 3/6/2018 Spectacle Presentation SCHEMA DEFINITION LANGU A GE http://localhost:3000/#/6?export 8/48

  9. 3/6/2018 Spectacle Presentation http://localhost:3000/#/6?export 9/48

  10. 3/6/2018 Spectacle Presentation Queries { drafts { title } } http://localhost:3000/#/6?export 10/48

  11. 3/6/2018 Spectacle Presentation R esults { "data" { "drafts": [{ "title": "Solving World Hunger" }] } } http://localhost:3000/#/6?export 11/48

  12. 3/6/2018 Spectacle Presentation blog schema type Post { id: String ! title: String ! publishedAt: DateTime ! likes: Int ! @default(value: 0) blog: Blog @relation(name: "Posts") } type Blog { id: String ! name: String ! description: String , posts: [ Post !]! @relation(name: "Posts") } http://localhost:3000/#/6?export 12/48

  13. 3/6/2018 Spectacle Presentation type Post { Arra y s id: String ! title: String ! publishedAt: DateTime ! likes: Int ! @default(value: 0) blog: Blog @relation(name: "Posts") } type Blog { id: String ! name: String ! description: String , posts: [ Post !]! @relation(name: "Posts") } http://localhost:3000/#/6?export 13/48

  14. 3/6/2018 Spectacle Presentation DIRE C TIVES EVER YTHING ELSE http://localhost:3000/#/6?export 14/48

  15. 3/6/2018 Spectacle Presentation RESOL VERS http://localhost:3000/#/6?export 15/48

  16. 3/6/2018 Spectacle Presentation T rivial R esolv er s Human : { name( obj args context , , ) { return obj name . } } http://localhost:3000/#/6?export 16/48

  17. 3/6/2018 Spectacle Presentation Async R esolv er s human( obj args context , , ) { return context db . .loadHumanByID( args id . ).then( userData => new Human( userData ) ) } http://localhost:3000/#/6?export 17/48

  18. 3/6/2018 Spectacle Presentation Dir ectiv e R esolv er s directive @upper on FIELD_DEFINITION type Query { hello: String @upper } http://localhost:3000/#/6?export 18/48

  19. 3/6/2018 Spectacle Presentation Dir ectiv e R esolv er s upper( next src args context , , , ) { return next().then(( str ) => { if (typeof( str ) === 'string') { return str .toUpperCase(); } return str ; }); } http://localhost:3000/#/6?export 19/48

  20. 3/6/2018 Spectacle Presentation SCENARIO 1 A Ne w P r oduct http://localhost:3000/#/6?export 20/48

  21. 3/6/2018 Spectacle Presentation http://localhost:3000/#/6?export 21/48

  22. 3/6/2018 Spectacle Presentation http://localhost:3000/#/6?export 22/48

  23. 3/6/2018 Spectacle Presentation R esolving with SQL return mysql query . (`SELECT "user"."id" AS "id", "posts"."id" AS "postId", "posts"."title" AS "postTitle", "posts"."body" AS "postText", "posts"."tags" AS "postTags", "posts"."created" AS "postCreated", FROM accounts AS "user" LEFT JOIN posts ON "user". id = "posts". authorId WHERE "user". id ${obj id} = . AND isPublished = 1 LIMIT ${args skip} . , 1000`) http://localhost:3000/#/6?export 23/48

  24. 3/6/2018 Spectacle Presentation SQL with P risma publicPosts( obj args ctx info , , , ) { return ctx prisma query . . .posts( where : { author id obj id : { : . }, isPublished : true, }, skip args skip : . , info // enables schema stitching ) } http://localhost:3000/#/6?export 24/48

  25. 3/6/2018 Spectacle Presentation prisma init ➜ prisma init full-03 ? How to set up a new Prisma service? Minimal setup: database-only ❯ GraphQL server/fullstack boilerplate (recommended) http://localhost:3000/#/6?export 25/48

  26. 3/6/2018 Spectacle Presentation prisma init ➜ prisma init full-03 ? How to set up a new Prisma service? Running $ graphql create ... ? Choose GraphQL boilerplate project: ❯ node-basic Basic GraphQL server (incl. database) node-advanced GraphQL server (incl. database & authentication) typescript-basic Basic GraphQL server (incl. database) typescript-advanced GraphQL server (incl. database & authentication) react-fullstack-basic React app + GraphQL server (incl. database ) http://localhost:3000/#/6?export 26/48

  27. 3/6/2018 Spectacle Presentation prisma deplo y [graphql create] Running boilerplate install script... Running $ prisma deploy... ? Please choose the cluster you want to deploy "full-03@dev" to prisma-eu1 Public development cluster prisma-us1 Public development cluster ❯ local Local cluster (requires Docker) http://localhost:3000/#/6?export 27/48

  28. 3/6/2018 Spectacle Presentation prisma deplo y Changes: Post (Type) + Created type `Post` + Created field `id` of type `GraphQLID!` + Created field `isPublished` of type `Boolean!` + Created field `title` of type `String!` + Created field `text` of type `String!` + Created field `updatedAt` of type `DateTime!` + Created field `createdAt` of type `DateTime!` Applying changes 1.1s Hooks: Importing seed dataset from `seed.graphql` 498ms Writing database schema to `src/generated/prisma.graphql` 0ms http://localhost:3000/#/6?export 28/48

  29. 3/6/2018 Spectacle Presentation tr ee . � I node _ modules ➜ tree . -I node_modules . ├── README.md ├── database │ ├── datamodel.graphql │ ├── prisma.yml │ └── seed.graphql ├── package.json ├── src │ ├── generated │ │ └── prisma.graphql │ ├── index.js │ └── schema.graphql └── yarn.lock 3 directories, 9 files http://localhost:3000/#/6?export 29/48

  30. 3/6/2018 Spectacle Presentation Schema type Post { id: ID ! @unique isPublished: Boolean ! @default(value: false) title: String ! text: String ! } http://localhost:3000/#/6?export 30/48

  31. 3/6/2018 Spectacle Presentation Seeds mutation { first: createPost (data: { title: "Hello World" text: "This is my first blog post ever!" isPublished: true }) { id } second: createPost (data: { title: "My Second Post" text: "My first post was good, but this one is better!" isPublished: true }) { id } third: createPost (data: { title: "Solving World Hunger" text: "This is a draft..." isPublished: false }) { id } } http://localhost:3000/#/6?export 31/48

  32. 3/6/2018 Spectacle Presentation pla y gr ound ➜ yarn playground yarn run v1.3.2 $ graphql playground Serving playground at http://localhost:3000/playground http://localhost:3000/#/6?export 32/48

  33. 3/6/2018 Spectacle Presentation pla y gr ound brew cask install graphql-playground http://localhost:3000/#/6?export 33/48

  34. 3/6/2018 Spectacle Presentation http://localhost:3000/#/6?export 34/48

  35. 3/6/2018 Spectacle Presentation Updating type Post { id: ID ! @unique isPublished: Boolean ! @default(value: false) title: String ! @deprecated title2: String text: String ! } http://localhost:3000/#/6?export 35/48

  36. 3/6/2018 Spectacle Presentation Updating ➜ yarn prisma deploy Changes: Post (Type) + Created field `title2` of type `String` Applying changes 1.1s Your GraphQL database endpoint is live: HTTP: http://localhost:4466/full-03/dev WS: ws://localhost:4466/full-03/dev http://localhost:3000/#/6?export 36/48

  37. 3/6/2018 Spectacle Presentation SCENARIO 2 Fr ontend http://localhost:3000/#/6?export 37/48

  38. 3/6/2018 Spectacle Presentation graphql - f ak er http://localhost:3000/#/6?export 38/48

  39. 3/6/2018 Spectacle Presentation F ak er Dir ectiv es type Person { name: String @fake(type: firstName ) gender: String @examples(values: ["male", "female"]) } http://localhost:3000/#/6?export 39/48

  40. 3/6/2018 Spectacle Presentation http://localhost:3000/#/6?export 40/48

  41. 3/6/2018 Spectacle Presentation Apollo Boost apollo - client apollo - cache - inmemory apollo - link - http apollo - link - err or apollo - link - state graphql - tag http://localhost:3000/#/6?export 41/48

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend