フロントエンドは TypeScript によって型安全な世界を構築することがかなり容易に、そして標準的な手法になってきました。しかしその型安全を壊す最後の存在は、API からのレスポンスです。

バックエンドでよく使われる言語のうち、型安全を担保できないタイプの言語(Rails, Python, PHP)によって書かれた API は、型が明確でないか、もしくはドキュメント等を通して情報を共有しないと、レスポンスの型が明確になりません。いうまでもありませんが、GraphQL の優位点は、フロント側からも Shema が取得できるので、型が明確になる点にあることはいうことです。

ただし、GraphQL の resolver を書くのはそれなりに時間がかかりました。CRUD 処理のような頻出する処理のためにも、かなりコードを書かないといけません。

そこで Hasura です。Hasura は Postgres database と Postgres database に対する query, mutation, subscription が用意された GrapQL API Server を提供します。

また auth0 といった認証 Sass との連携、マイクロサービスの推奨等、モノシリック具合とマイクロサービス間のバランスが現実的です。

フロントエンドエンジニアが Hasura を使ってウェブアプリケーションを開発することで、型安全かつ生産性の高い開発が可能になります。

I'm Nakanishi Yusuke, JavaScript developer. So the talk today is especially on my work situation as a JavaScript dveloper. I mean no disrespect to other laguage or duties.

As you may know, the world of web is vast. I think many of you are working in this area. And unfortunately or fortunately, the development of client side is restricted to JS, Virtually. So we write a lot of code every day. React, JSX, CSS in JS. A lot of code. And Finally, we got a most powerful hoe(hóu) for cultivating vast westland. That is TypeScript. The power of TypeScript is type and type checking. We'll never get a error like: "getUsers is not a function." or "users.map is not a funtion." I know! Certainly I know! We'll never meet again.

But our Fertile(fə́ːrtəl) ground need rain. The rain water. Crops grow with rain water. This is metaphor for API Reseponse. API reseponse is polluted. That has no Type. Just a JSON. The mother earth will be contaminated(kəntǽminèit) with polluted rain. Save the mother earth.

This is where the GraphQL comes in. As you know, GraphQL endpoint tell us the type of API responses. Moreover, we got typescript type definitions by using graphql-code-generator. That makes our app type-safe from front-end to back-end.

But there are some problems left to handle.

  • Is reslover type definition correct?
  • How we access to DB?

While GraphQL endpoint tell us type, but that is cannot be assured. You can write incorrect resolver schema.

This is where the Hasura comes in.

haura

Hasura engine is combination of GraphQL API server and PostgresDB.

Demo time.

But I've yet used Hasura in produciton. Where the tool can be used in prodction or not is the most importanant factor. Sometime soon I'll try it.

And if you know more better tool. Please tell me that.

And I'm looking for JavaScript first fullstack enginner friends. Please visit my site, uncle-javascirt.com and contact me.