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

Evolving the Graph

jnwng
June 21, 2019

Evolving the Graph

Coursera has had GraphQL in production for over three years now — here's the story of how we started, what things have stood the test of time, and what things haven't.

jnwng

June 21, 2019
Tweet

More Decks by jnwng

Other Decks in Technology

Transcript

  1. Evolving the Graph
    GraphQL Conf 2019

    View full-size slide

  2. jon wong
    @jnwng
    developer experience

    View full-size slide

  3. we envision a world
    where anyone,
    anywhere can transform
    their life by accessing
    the world’s best learning
    experience.

    View full-size slide

  4. (p.s., we're hiring in
    mountain view and
    toronto)

    View full-size slide

  5. Evolving the Graph
    GraphQL Conf 2019

    View full-size slide

  6. Evolving Our Graph
    GraphQL Conf 2019

    View full-size slide

  7. DISCLAIMER
    Take everything beyond
    with a large Coursera-
    sized grain of salt.
    What works for our team may not work for yours.

    View full-size slide

  8. Coursera has been
    using GraphQL for
    over three years!

    View full-size slide

  9. GraphQL Three Years Ago
    We wanted a "data-first"
    solution to reflect our
    REST APIs in GraphQL

    View full-size slide

  10. GraphQL Three Years Ago
    Clients were responsible
    for calling for the correct
    data for themselves.

    View full-size slide

  11. The Tools
    (three years ago)

    View full-size slide

  12. Code-first Schema
    Generation

    View full-size slide

  13. Schema Stitching

    View full-size slide

  14. Lessons Learned
    (three years later)

    View full-size slide

  15. Federation meant teams
    could retain ownership
    over their services.

    View full-size slide

  16. Federation with REST
    meant we only had one
    GraphQL resolver

    View full-size slide

  17. Federation with REST
    meant you previewed
    changes in production.

    View full-size slide

  18. Code-first Schema
    Generation

    View full-size slide

  19. Code Generation
    It was really simple to
    get existing REST
    resources into our
    schema.

    View full-size slide

  20. Code Generation
    It was really simple to
    get existing REST
    resources into our
    schema.

    View full-size slide

  21. Code Generation
    ~ 7,546 types
    ~ 664 root fields

    View full-size slide

  22. Schema Stitching

    View full-size slide

  23. Schema Stitching
    Namespacing our
    types gave our
    graph room to
    grow.
    We have ~600+ distinct REST resources.

    View full-size slide

  24. Schema Stitching
    We never had to figure
    out how to "deprecate" a
    field

    View full-size slide

  25. Some things
    surprised us.

    View full-size slide

  26. GraphQL clients
    are incredibly
    powerful
    For every feature our servers didn't have, our
    clients could add support.

    View full-size slide

  27. Our implementation of
    GraphQL didn't look like
    GraphQL in the wild.

    View full-size slide

  28. Our Biggest
    Realization

    View full-size slide

  29. Is a data-first schema the
    best use of GraphQL?

    View full-size slide

  30. The schema of your
    service is not always the
    same as the schema you
    want for your client.

    View full-size slide

  31. Clients don't just
    need data, they
    need information.

    View full-size slide

  32. Where We Go From
    Here

    View full-size slide

  33. Optimizing for quality of
    schema over quantity of
    schema.

    View full-size slide

  34. Coordination between
    engineers happens with
    GraphQL schemas as our
    common language.

    View full-size slide

  35. We're vastly more
    intentional about what
    goes into the schema.

    View full-size slide

  36. The graph doesn't
    evolve, people do.

    View full-size slide

  37. Thanks!
    @jnwng

    View full-size slide