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

GraphQL

Dimitri
January 25, 2019

 GraphQL

A simple introduction to what exactly GraphQL is, how you create your own GraphQL API's, and how it compares to REST API's.

Dimitri

January 25, 2019
Tweet

More Decks by Dimitri

Other Decks in Programming

Transcript

  1. Tech talk

    View Slide

  2. “ GraphQL is a query language for your API, and a
    server-side runtime for executing queries by using a
    type system you define for your data. GraphQL isn't
    tied to any specific database or storage engine and is
    instead backed by your existing code and data. ”
    – Taken from Introduction to GraphQL
    What is GraphQL?

    View Slide

  3. What about REST?
    REST GraphQL
    Multiple endpoints Single endpoint
    Fixed response structure(s) Fetch what you need
    No specification Query language
    Separate documentation Documented schema
    HTTP Protocol-agnostic

    View Slide

  4. Query language

    View Slide

  5. Query language
    +

    View Slide

  6. Specification
    GraphQL
    Schema
    Types
    Resolvers
    Mutations
    Query
    Scalars
    Inputs

    View Slide

  7. What is a type?

    View Slide

  8. What is a query type?

    View Slide

  9. What is a mutation type?

    View Slide

  10. What is an input type?

    View Slide

  11. What are resolvers?

    View Slide

  12. What are resolvers?

    View Slide

  13. Live coding

    View Slide

  14. Silver bullet?
    - N + 1 problem
    - Caching
    - File uploads
    - Security

    View Slide

  15. Resources
    - Specification: https://graphql.org/
    - Apollo GraphQL platform: https://www.apollographql.com/
    - Java implementatie: https://www.graphql-java.com/
    - Spring boot starter: https://www.graphql-java-kickstart.com/spring-boot/
    - My blogpost: https://blog.optis.be/exploring-graphql-3de51e39d707
    - Source code: https://github.com/optis/tech-talk-graphql

    View Slide

  16. The End

    View Slide