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

Building a GraphQL client in Elm For Elm

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

Building a GraphQL client in Elm For Elm

This presentation introduces
- Elm
- GraphQL
- Motivates why GraphQL is a good logical step as a data layer for Elm

Avatar for Karthik Venkateswaran

Karthik Venkateswaran

September 23, 2019

Other Decks in Programming

Transcript

  1. Elm

  2. - Programming language for declaratively creating applications for the web

    - Purely functional - Statically typed - Immutable - Compiles to HTML, CSS, JS :)
  3. Simple pattern for architecting web apps. Key focus is on

    code reuse, modularity and testing. It splits the application logic into three separate functions
  4. - Model: Stores the state of the application - View:

    Renders the application on the UI - Update: Handles any user interaction and keeps the model and view in sync
  5. - Stateful applications require data to be stored at a

    secure location and be fetchable via API’s - Applications consume the API to service customer via a network call (async) - Options - SOAP - REST - ?
  6. - Open source query and data manipulation language for API’s

    - It was developed by facebook in 2012 and made the spec and the reference implementation for javascript publicly available in 2015 - Designed with following principles - Strong typing - Introspective - Client specified queries etc..,
  7. - Elm as we learnt is a functional programming language

    with a strong type system. Using a language which is also designed with same set of principles goes well together. - GraphQL schema can be easily translated into Elm types and will prove to be a great data layer for Elm apps. - Resolves issues with data fetching and manipulation and ensures that if the program compiles, it works
  8. - GraphQL as it is can be used directly in

    elm program similar to rest by encoding the queries as strings and going through a series of data transformation to get the data into elm types for usage - The above approach will work but it will be at a cost a lot of repeated boilerplate code which can be easily abstracted and simplified.
  9. In this talk we will look at - Key problems

    of using GraphQL directly - Explore ways on how we can improve the experience by abstracting key parts (query, mutation functions) using elm types. - We will then use it to interact with our GraphQL server
  10. - Learn Elm language and be able to build web

    applications using it - Have better understanding of Elm type system and how to write your own custom DSL to query GraphQL - Be in a position to evaluate GraphQL and/or Elm for your next project