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

Intro to GraphQL

Intro to GraphQL

Praveen Durairaj

October 05, 2019
Tweet

More Decks by Praveen Durairaj

Other Decks in Programming

Transcript

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

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

    Type System • Introspection • Client side tooling • Caching ?
  3. 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.
  4. GraphQL Schema: Typesystem of API type User { id: Int

    name: String address: Address } type Address { id: Int street: String city: String }
  5. Server • Define schema • Define resolvers type User {

    id: Int name: String address: Address } const resolvers = { Query: { user: () => users, }, };
  6. REST Killer? • GraphQL enhances REST ◦ Easy to query

    ◦ Self Documented ◦ Client side performance (less round trips)