GraphQL with Graphene and Django, Laughters and Tears

摘要

這不是教學。我希望為曾經使用過 web API 的人,不論是哪一種 API,都能帶來一些啟發,以及微笑。

我會先簡述一下過往用 Python 寫裸 API,到 REST API,到目前 GraphQL 的心路歷程,再展示 iCHEF 在 GraphQL 的《**三**》代演進,以及一些後見之明,為來者鋪路。

聽完應該會對 GraphQL 在 web 前後端與 mobile 的應用場景有更多的掌握,在 API 的設計與使用多一些他山之石,以及用 Graphene 與 Django 實作 GraphQL schema 時能預想到一些細節與工具。

In English:
It's NOT a tutorial. Hoping it can bring some delights to people who ever used Python to call the web API, whatever kind that API is.

I will brief my experience of writing Python from raw API, REST API, to current GraphQL API. >> 3 << generations of iCHEF GraphQL will be demonstrated to pave the road of followers.

It should bring more understanding of GraphQL interaction between web frontend, backend, and mobile clients, more examples of API design & usage, and details of GraphQL schema implement in Graphene & Django.

說明

GraphQL 是繼 REST API 標準之後的新起之秀。承接多年來的 REST API 的經驗,始由 Facebook 內部開發人員所實作,一套更符合現代 API 開發的原則與風格。目前交[由 Linux 基金會主導並發起為 GraphQL 成立獨立的基金會](https://www.linuxfoundation.org/press-release/2018/11/intent_to_form_graphql/)。 GraphQL 在 iCHEF 中被用於行動裝置、前端網頁框架與雲後端的溝通。這個講題會簡述它的優缺點,過程中所遇到在程式設計、產品設計、團隊溝通、測試、佈署,以及效能與管理監測上的優缺點以及離開 REST 的挑戰。或所謂的他山之石。 GraphQL is the next API goto choice after REST API standard. Started in Facebook internal project, now it's [hold by Linux Foundation and intending to form a independent foundation](https://www.linuxfoundation.org/press-release/2018/11/intent_to_form_graphql/). In iCHEF, it's served for both web frontend (react) and iOS client (iPad) to communicate with cloud backend (AWS ECS, Django). This talk will brief its pros and cons on API fields typing, schema-driven, and how they work with iCHEF tech evolution during programming, production design, team communication, testing, deployment, and performance monitoring stages. --- Related talks: - [Win back lovely API - GraphQL in Python, Keith Yang, May 2018, PyCon](https://yang.keitheis.org/talks/win-back-lovely-api-graphql-in-python/) - [Reactive Programming in Python, Keith Yang, 2016](https://keitheis.github.io/reactive-programming-in-python/)

講者

Keith Yang

最近覺得邊騎室內腳踏車邊用電腦,離開臉書與 IG 的精神(神經?)生活很不賴。讓這隻小白鼠從大眾心理控制實驗學裡喘了一小口氣。

Recently he enjoys skateboard commute, still coffee-achemy, and indoor cycle while programming or gaming, an awesome mind vocation of leaving FB and IG.

Keith is the founder and co-organizer of Taipei.py, largest Python user group in Taiwan, a Lead Software Engineer at iCHEF, and was Chairperson of PyCon APAC 2015. His work mostly focuses on web/backend/cloud services since 2006, and he hands on kernel tools of virtualization on hypervisors in 2016.