grap aphql hql forget the rest
play

Grap aphQL hQL forget (the) REST? Christian Schwendtner - PowerPoint PPT Presentation

Grap aphQL hQL forget (the) REST? Christian Schwendtner https://www.pexels.com/photo/man-person-people-emotions-1990/ https://www.pexels.com/photo/man-person-people-emotions-1990/ REST Feelings Im lovin it Well, What else?


  1. Grap aphQL hQL – forget (the) REST? Christian Schwendtner

  2. https://www.pexels.com/photo/man-person-people-emotions-1990/

  3. https://www.pexels.com/photo/man-person-people-emotions-1990/

  4. REST – Feelings I’m lovin ’ it Well, … What else?

  5. Agenda Why Let’s talk about REST Challenges What GraphQL in Action GraphQL Features How GraphQL on the Server GraphQL on the Client

  6. Let’s talk about REST

  7. https://www.pexels.com/photo/adult-casual-collection-fashion-296881/

  8. Richardson Maturity Model Glory y of REST ST Level 3: Hypermedia Controls Level 2: HTTP Verbs Level 1: Resources Level 0: The Swamp of POX https://martinfowler.com/articles/richardsonMaturityModel.html

  9. Challenges

  10. The BookStore aka “ Amazon (very) light” Books Algorithms to Live By Brian Christian * 1 Book Author Cracking the Coding Interview Gayle Laakmann McDowell Life 3.0 Max T egmark

  11. Interaction GET /books Books [ book: { title, …, authorURL } ] Algorithms to Live By GET /authors/1 Brian Christian { firstName, lastName , … } Cracking the Coding Interview Server GET /authors/14 Gayle Laakmann McDowell { firstName, lastName , … } Life 3.0 GET /authors/98 Max T egmark { firstName, lastName , … }

  12. https://www.pexels.com/photo/adult-alcohol-blur-celebrate-290316/ https://www.pexels.com/photo/time-lapse-photography-of-water-bobbling-beside-lemon-fruit-161425/

  13. “Custom Endpoints”? GET /books_overview GET /books?dataset=books_with_authors GET /books?dataset=books_with_authors_with_ratings GET /books?dataset=books_with_authors_with_all_i_will_ever_need GET /books?dataset=books_with_authors_with_all_i_will_ever_need2

  14. “Custom Endpoints” Multiple views? Multiple client types? Multiple client versions? Private / Public API GET /books?include=book.title,author.lastName,author.firstName

  15. GraphQL A query language for your API

  16. Just st for once, ce, let t me me look k on you with th my my own n eyes es . . An Anakin kin Skywal ywalker er https://pixabay.com/en/star-wars-warrior-space-cinema-2473201/

  17. Graph i QL

  18. GraphQL is … Specification Reference implementation Schema (domain specific) Independent of the data store Independent of the transport protocol

  19. GraphQL Features

  20. GraphQL Operations Query Read Mutation Write Subscription Notification (“Event”)

  21. Fields query { books { title author { firstName lastName } } }

  22. Arguments query { books(first: 2) { title author { firstName lastName } } }

  23. Aliases query { books { title author { firstName lastName smallPic: profilePic(size: SMALL) largePic: profilePic(size: LARGE) } } }

  24. Fragments fragment authorFragment on Author { firstName lastName } query { books { title author { ...authorFragment } } }

  25. Variables query($limit: Int) { books(first: $limit) { title author { firstName lastName } } }

  26. Validation / Errors

  27. Introspection

  28. Mutations mutation { voteBook(bookId: 1) { id votes } }

  29. May the force be with you https://pixabay.com/en/star-wars-lightsaber-laser-sword-2369317/

  30. Schema type Book { type Query { id: Int! books(first: Int): [Book] title: String authors: [Author] ... } author: Author } type Mutation { type Author { voteBook(bookId: Int!): Book id: Int! } firstName: String lastName: String ... books: [Book] }

  31. GraphQL on the Server

  32. Resolvers books() query { books { }, … ] [ b book1 k1 { } }, book2 k2 { } title title() title() author() author() author { “Algorithms …” author or { } } author or { } } “Cracking the ...” firstName lastName firstName() lastName() firstName() lastName() } } “Gayle” “Brian” “Christian” “ Laak akmann mann ” }

  33. Execution query { books { db.getAllBooks() title author { db.getAuthorForBook(1) firstName db.getAuthorForBook(2) Caching lastName db.getAuthorForBook(3) Batching } db.getAuthorForBook(4) } db.getAuthorForBook(5) DataLoader } db.getAuthorForBook(6) https://github.com/facebook/dataloader

  34. GraphQL on the Client

  35. Client GET / POS OST Relay https://facebook.github.io/relay Client https://www.apollographql.com/client

  36. UI - Structure Books <book-list> <book-info> Algorithms to Live By Brian Christian < author-info > Cracking the Coding Interview <book-info> Gayle Laakmann McDowell <author-info> <book-info> Life 3.0 <author-info> Max T egmark

  37. Version 1 <book-list> query { <book-info> books { title <author-info> author { firstName lastName profilePic } } }

  38. Version 2 <book-list> query bookList { <book-info> books { ...book fragment book <author-info> on Book { } title } fragment author on Author { author { firstName ...author lastName } profilePic } }

  39. <author-info> TypeScript fragment author export interface author Fragment = { on Author { firstName: string | null, firstName lastName: string | null, codegen lastName profilePic: string | null, profilePic }; }

  40. REST vs GraphQL https://www.pexels.com/photo/man-couple-people-woman-343/

  41. One last note: GraphQL as Gateway Client GraphQL Service A Service B Service C

  42. GraphQL – REST in peace https://www.pexels.com/photo/photo-of-a-hippie-woman-736603/

  43. Christian Schwendtner PROGRAMMIERFABRIK GmbH @CSchwendtner

  44. https://www.pexels.com/photo/adult-chill-computer-connection-450271/

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