<  Back to Schedule
GraphQL in ProductionSession Presentations

Incrementally Adopting GraphQL and Relay at Pinterest

Tuesday, September 10 / 11:40a.m. PDT - 12:10p.m. PDT
Mauricio Montalvo Profile Image
Mauricio MontalvoPinterest, Senior Software Engineer

Pinterest is too large to simply “rewrite our app” to use GraphQL in one fell swoop. Even migrating an individual screen takes months, at our scale this is quite challenging, like changing a plane’s engine while flying. Is GraphQL adoption destined to be difficult for large companies? Can this process be made more incremental? Unfortunately, the answer seems to be no. It's hard to imagine how components consuming GraphQL data can coexist on a page that makes network requests to a REST endpoint. And yet, we figured it out. And we had a good time, too! We designed Relay-compatible APIs that allow us to read data either from a GraphQL store or from arbitrary objects (e.g. from Redux.) So, engineers can migrate individual components within a larger tree. These components specify the data they need using a fragment, and receive GraphQL-shaped data, regardless of whether the data came from GraphQL or REST. When a component tree is fully migrated, we're able to A/B test the REST and GraphQL endpoints, and only turn on GraphQL when we're sure doing so won't degrade any metrics. And we're about to release this to open source: adopting GraphQL on the front-end has never been easier!