Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tai2
Created May 30, 2017 08:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tai2/7607a018625864c0469c29a3158d3ddd to your computer and use it in GitHub Desktop.
Save tai2/7607a018625864c0469c29a3158d3ddd to your computer and use it in GitHub Desktop.

GraphQLのクライアントライブラリはどうあるべきか

jamesmacaulay/elm-graphql

クエリビルダ、内部DSLっぽく書けるやつ http://package.elm-lang.org/packages/jamesmacaulay/elm-graphql/latest

jahewson/elm-graphql

スキーマからソースコード生成するやつ https://github.com/jahewson/elm-graphql

静的にコード生成するメリット

  • スキーマとクエリの整合性チェックが事前にできる

デモ手順

  1. git clone https://github.com/jahewson/graphql-starwars.git
  2. cd graphql-starwars/ && npm i && npm start
  3. http://localhost:8080/ にアクセス
  4. git clone https://github.com/jahewson/elm-graphql-demo.git
  5. elm-package.json, src/StarWars.graphqlを確認
  6. elm graphql
  7. src/StarWars.elm確認
  8. introspection queryを確認
  9. elm-reactor
  10. 不正なクエリはコード生成時にエラーになることを確認
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment