-

Amsterdam, Netherlands
Back to Schedule

Mauricio Montalvo

Incrementally Adopting GraphQL and Relay at Pinterest

-
Metropolitan A
GraphQL in ProductionSession Presentations

Mauricio Montalvo

Senior Software Engineer, Pinterest

I’m a software engineer with 11 years of professional experience, I consider myself full-stack but my career has been focused in Frontend Development in the past years, I love creating web apps using ReactJS & GraphQL. At Pinterest, I’m part of the Web team that’s exploring the adoption of GraphQL in our systems, I’ve been working on this for 2 years now leading a GraphQL migration project since Q3 2023.

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!