Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Architecting Scalable Serverless applications with GraphQL Api using Hasura

Architecting Scalable Serverless applications with GraphQL Api using Hasura

In this talk, we will see what are the benefits of building event-driven Realtime GraphQL backend and what problems it will solve. We will see how we can bootstrap our GraphQL backend fast with free and open source Hasura engine and connect it to serverless functions for custom business logic, providing our web or mobile apps with infinitely scalable backend with modern GraphQL API.

Vladimir Novick

June 06, 2019
Tweet

More Decks by Vladimir Novick

Other Decks in Technology

Transcript

  1. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Architecting scalable serverless applications with GraphQL API using Hasura
  2. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Developer Advocate G D E , a u t h o r , c o n s u l t a n t Web, Mobile, Virtual Reality, Augmented Reality, Mixed Reality & Internet of Things
  3. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Let’s talk about Serverless
  4. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k
  5. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Let’s talk about REST
  6. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k The structure of request
  7. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k What is the problem with that?
  8. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k username address Some data More data Underfetching Multiple requests
  9. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k username city Some data More data Overfetching username street city Some data More data Too much data in a request
  10. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Solution GraphQL - a query language for your API
  11. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k
  12. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Your API models are “graph” like
  13. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k © learn.hasura.io
  14. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k GraphQL query
  15. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k You want to control how to get the data
  16. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k
  17. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k How to parameterise your API
  18. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k GET /api/user?id=1 Before GraphQL Set params programmatically
  19. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k GraphQL can take arguments
  20. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k And even accept variables
  21. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k With GraphQL GraphQL server gets 1. The GraphQL query 2. A variables object
  22. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k What about “Write” APIs
  23. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Before GraphQL
  24. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k With GraphQL
  25. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Realtime API
  26. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k • polling • websockets Before GraphQL
  27. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k With GraphQL
  28. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Documentation (before)
  29. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Documentation (after)
  30. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k GraphQL schema (SDL)
  31. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Introspection
  32. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k
  33. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Business benefits
  34. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k API on boarding • Exploring APIs is easy • Documentation is auto-generated • No versioning required for non-destructive changes • Auto-generated SDKs for all languages, community maintained

  35. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Agility for api customers • Auto-generated SDKs for all languages, community maintained • Auto-complete for API calls in their IDEs
  36. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Usage analytics • New information regarding what APIs users want is now available • What data is of interest to what users?
  37. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Now what about Architecture
  38. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Microservices architecture
  39. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k 3factor.app architecture
  40. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k See it in action h9ps:/ /serverless-demo.hasura.app/analy?cs-app/ https://serverless-demo.hasura.app/order-app/ Order app Analytics app
  41. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Hasura open source and free engine that gives you auto-generates real-Gme GraphQL API on top of new or exisGng Postgres database h9ps:/ /github.com/hasura/graphql-engine
  42. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k
  43. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Features • Can be deployed to any cloud or run locally • CompaGble with all AuthenGcaGon soluGons • Can run on top of new or exisGng Postgres database • Supports Postgres addons (PostGIS, TimescaleDB) • Auto-generates GraphQL api • GraphQL queries are compiled to performant SQL statements using naGve Postgres features
  44. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Features • Comes with hasura-cli which has awesome tools like migraGons and more • Can work with custom SQL statements • Has configurable access controls for data • Can be connected to your own GraphQL server (does schema sGtching) • Has evenGng system which enables to trigger serverless funcGons
  45. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k How to get started
  46. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Go to hasura.io and pick your stack
  47. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Hasura console overview
  48. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k GraphiQL on steroids h9ps:/ /world-congress-demo.herokuapp.com/v1/graphql
  49. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Data tab Db browsing, data modeling, custom SQL, relationships, access control
  50. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Remote schemas Stitch GraphQL schemas, custom resolvers
  51. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Event triggers Trigger serverless functions on database events
  52. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Want to learn more? React, Vue, Angular, React NaGve, iOS, Android, FluUer, Elm, ReasonML h9ps:/ /learn.hasura.io/
  53. v n o v i c k . c o

    m @ V l a d i m i r N o v i c k Thank you