$30 off During Our Annual Pro Sale. View Details »

Intro to GraphQL

Intro to GraphQL

Praveen Durairaj

October 05, 2019
Tweet

More Decks by Praveen Durairaj

Other Decks in Programming

Transcript

  1. None
  2. Intro to GraphQL - Praveen @praveenweb praveenweb

  3. Query Language • Specification for APIs • Special Syntax •

    Backend and Database agnostic • Complex data/nested relationships
  4. Comparing to REST? • Single Endpoint (/graphql) • Schema with

    Type System • Introspection • Client side tooling • Caching ?
  5. API Call Attempt Query Params? username Street City username City

    Show less data on mobile
  6. None
  7. None
  8. Graph like You want to control the data you get

    User: Id Name Address: Street City Orders: Id Product Product: Id Name Photo Brand Brand: Id Name Your API models are “graph” like.
  9. GraphQL Schema: Typesystem of API type User { id: Int

    name: String address: Address } type Address { id: Int street: String city: String }
  10. Queries - Fetch data • Type • Operation Name •

    Variables • Fields
  11. Mutations • Insert • Update • Delete

  12. Subscriptions • Realtime data • Easy to consume

  13. Server • Define schema • Define resolvers type User {

    id: Int name: String address: Address } const resolvers = { Query: { user: () => users, }, };
  14. Query Patterns • Fetch data • Smart client side cache

    • Dataloader - Batching
  15. Query Patterns • Fragments • Reusable parts

  16. Mutation Patterns • Insert and update cache • Optimistic update

  17. Subscription Patterns • Polling ? • Live Queries • Notifications

    (event based) • Demo
  18. GraphQL = Unified API Layer Databases App GraphQL Server SaaS

    APIs Microservices
  19. GraphQL = Unified API Layer • Federation - Apollo •

    Remote Joins - Hasura
  20. REST Killer?

  21. REST Killer? • GraphQL enhances REST ◦ Easy to query

    ◦ Self Documented ◦ Client side performance (less round trips)
  22. GraphQL is evolving @praveenweb praveenweb