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

GraphQL & Ember

Chris Ball
February 21, 2018

GraphQL & Ember

A presentation at the Boston Ember group going over GraphQL and how to integrate it into your app.

Chris Ball

February 21, 2018
Tweet

More Decks by Chris Ball

Other Decks in Programming

Transcript

  1. &

    View Slide

  2. Chris Ball
    cball_

    View Slide

  3. Disclaimers

    View Slide

  4. vs

    View Slide

  5. vs

    View Slide

  6. vs

    View Slide

  7. These are all tools to
    build apps.

    View Slide

  8. You are not your tools.

    View Slide

  9. What is GraphQL?

    View Slide

  10. A specification that
    enforces a schema.

    View Slide

  11. The schema validates

    client requests.

    View Slide

  12. An application layer.

    View Slide

  13. Gives power to

    the client.

    View Slide

  14. What?!

    View Slide

  15. Here’s a schema.

    View Slide

  16. View Slide

  17. 2 Special Schema Types.

    View Slide

  18. Query

    View Slide

  19. View Slide

  20. Mutation

    View Slide

  21. Variables!

    View Slide

  22. GraphQL
    Advantages

    View Slide

  23. Advantages
    ★ No more “hey can you make this endpoint

    return this now?” discussions
    ★ Reduce number of requests
    ★ Smaller payloads (return only what you need)
    ★ camelCase conventions
    ★ Client determines shape of response
    ★ Subscriptions / websockets built in

    View Slide

  24. Advantages
    ★ “Wrap” an existing REST API
    ★ Schema Stitching to combine multiple GQL APIs as one
    ★ No more thinking about requests/responses
    ★ Tooling: GraphiQL is amazing
    ★ Introspection: Client can send query to get the schema
    ★ Fragments

    View Slide

  25. GraphiQL & Introspection

    View Slide

  26. Ok, how can I use
    this in Ember?

    View Slide

  27. View Slide

  28. View Slide

  29. I was going to show examples using

    View Slide

  30. View Slide

  31. View Slide

  32. Configure Apollo

    View Slide

  33. Do some queries

    View Slide

  34. View Slide

  35. View Slide

  36. View Slide

  37. View Slide

  38. View Slide

  39. View Slide

  40. View Slide

  41. How do I fetch a different org?

    View Slide

  42. View Slide

  43. Cool story. How do you query 

    for multiple items?

    View Slide

  44. View Slide

  45. View Slide

  46. View Slide

  47. Do a mutation

    View Slide

  48. View Slide

  49. View Slide

  50. Subscriptions

    are also a thing.

    View Slide

  51. Ember Data?

    View Slide

  52. View Slide

  53. What about Tests /
    Mocking / Mirage?

    View Slide

  54. View Slide

  55. https://github.com/bgentry/ember-apollo-client/blob/master/tests/helpers/start-pretender.js
    https://www.apollographql.com/docs/link/links/schema.html#Mocking

    View Slide

  56. Different Folder
    Structure?

    View Slide

  57. View Slide

  58. https://github.com/bgentry/ember-apollo-client/blob/master/tests/helpers/start-pretender.js
    https://www.apollographql.com/docs/link/links/schema.html#Mocking

    View Slide

  59. Resources

    View Slide

  60. https://github.com/bgentry/ember-apollo-client
    http://graphql.org/learn/
    https://www.apollographql.com/docs
    http://graphql.org/blog/rest-api-graphql-wrapper/
    https://www.howtographql.com/ember-apollo

    View Slide