More than a year ago, Handshake’s engineering team decided to gradually migrate our REST API surface toGraphQL. On the iOS side, we needed a client solution that worked well with our existing stack and allowed for that gradual migration–to support things like building the same model object from both a REST and a GraphQL response. We spent some time evaluating the industry standardApollobut found that it would make the migration more involved: we’d have to buy in wholesale and replace a lot of what we had already built rather than adding a layer to our current architecture. Instead, we decided to create our own solution: a very thin GraphQL abstraction that uses our existing networking and modeling infrastructure.
In the intervening time, we’ve seen only good things from this decision. Although we remained open to the idea, we have yet to come across any situations where we’d need to backtrack and start using Apollo (or some other library). And we’ve found it easy to expand our implementation where we needed–most significantly in merging on-disk models with partial results from the API–because the client code itself is so modest. As we’ve continued to build up our GraphQL API surface, we’ve found particular value in the pagination support, given that our app, like many, is composed mostly of infinitely scrolling tables.
As expected, we’ve seen real benefits from GraphQL in its own right. There are many places in the app where we’re using the same API for mobile and the web, no adaptation required. In some cases, we’re even using the exact same queries. But this library in particular, rather than implementing Apollo or some other solution, has given us the best of both worlds. We’re still supporting our existing REST APIs, with no code changes required, even as we transition to GraphQL. We’ve saved enormous developer time not having to change anything in that side of the codebase, and we look forward to someday deleting it all with no additional maintenance along the way.
In fact, we’ve had such success that Igave a talk about itatiOSDevUK, explaining our decision process and implementation. In that talk, I said that we planned to release this code as an open-source library. And today, we’re happy to announce thatQuerl, Handshake’s minimal GraphQL client library for iOS, is freely available! You can install it via SwiftPM or Cocoapods.
The Opportunity Ahead
Open source technology has been gaining widespread attention and recognition in recent years as more and more individuals, businesses, and organizations embrace its benefits– and we’re excited to contribute. Whether you’re an aspiring technologist or an engineer,Querl’s READMEshould give you a good idea of how to use it. Still, we would love to see contributions–both to the documentation and to the actual implementation.
We wouldn’t have built this library if we didn’t think it would be valuable, and we’re eager to see what engineers outside of Handshake do with it. And as part of releasing this library, we had the chance to develop a Handshake-internal process to open source select code that we think might benefit the community. Stay tuned for a deeper dive into the process behind the process: how we went from a few ad hoc self-driven initiatives to a fine-tuned system that takes into account the needs of all parts of the company.
We hope this will be one of many contributions we can make to the broader engineering world.