Company
Date Published
Author
Brian Kane
Word count
1593
Language
English
Hacker News points
None

Summary

We started by building a REST API for Coursera to manage its courses, instructors, grades, and other related data. However, as our product scaled, we faced performance issues due to the number of round-trip requests required to fetch data. We considered adopting GraphQL but were hesitant due to the complexity of migrating over 1,000 existing endpoints. Instead, we added a GraphQL proxy layer on top of our REST APIs, which allowed us to dynamically translate our REST APIs to GraphQL. However, this approach proved to be short-lived as our GraphQL server initially failed due to an out-of-sync schema between our backend services and GraphQL. To address this issue, we automated the process of building our GraphQL layer by using tools provided by our REST framework, including a task that pings every downstream service every five minutes to fetch data. We also defined forward relations between resources using annotations, which allowed us to link models and resources together. Our GraphQL server has been running in production for over six months now, providing benefits such as easier discovery of data, improved type-safety, and faster page loading times, while minimizing the cost of developer productivity.