GraphQL a cut above the REST, say query lang's fans: Airbnb, Knotel, others embrace the tech
Data-fetching scheme seems to be catching on
At the GraphQL Summit in San Francisco on Wednesday, Matt DeBergalis, co-founder and CTO at data plumbing biz Apollo GraphQL, urged companies to appoint a data graph champion to help ease the implementation of GraphQL, a query language for fetching data.
It's not yet a given that organizations want to implement GraphQL. But at a gathering arranged by Apollo, which makes the de facto standard open-source client and the commercial Apollo GraphQL Platform, there's a certain incentive to imagine GraphQL everywhere.
It's already halfway there, at least among the 472 companies attending the show – about 52 per cent of organizations represented are already using the technology in production. Some of the more recognizable names include Airbnb, Audi, Expedia, The New York Times, Medium, PayPal, and Priceline.
GraphQL was created at Facebook in 2012 and released as an open-source project three years later. After a licensing change in 2017 and a move to the Linux Foundation last year, it has more or less settled down and come to terms with itself as a more capable alternative to REST. "Graph" in this context, while it has a technical definition, refers to structured data – entities and their relationships.
What is GraphQL?
Both REST and GraphQL provide ways to request data over HTTP. When using a REST API to make a GET request, you call a specified endpoint and receive a specific object, often in the form of JSON data.
GraphQL allows for greater flexibility with requests that are more like database queries. One query can be constructed to fetch data from multiple endpoints, so you get all the data you need at once. This sort of declarative data fetching turns out to particularly helpful on mobile devices, where network requests may consume limited battery and bandwidth resources.
GraphQL also has useful features like an introspection system. You can query the GraphQL schema – the data structure – and it will tell you the kinds of queries it supports. This allows for the auto-generation of API documentation, something developers consider to be fairly important as the outcry over Apple's documentation suggests.
Claire Hough, VP of engineering at Apollo, told The Register at the show that probably more than half of front end developers know about GraphQL. She said the technology is mature and ready for adoption but isn't yet baked into everything. Even so, she said, there are companies like AirBnB and Expedia that have gone all-in.
Facebook's open-source license drama-zone GraphQL gets swanky digs in Linux mansionREAD MORE
"We wanted to use TypeScript for this project because it can generate TypeScript types for queries directly to the [GraphQL] schema," she said. "We saw TypeScript as an absolute must in order to take advantage of the end-to-end type safety."
As to DeBergalis's advice to designate a data graph champion – someone responsible for managing infrastructure, data graph conventions and styles, decisions about what to measure, and so on – that may not be strictly necessary.
Knotel, an office space provider (like WeWork but without the dumpster fire), doesn't have a data graph champion, according to Victor Quinn, head of engineering at the biz. In a conversation with The Register, he explained, "I kind of step into that role a little bit just as the leader, but we don't have anyone with that title specifically."
Quinn said 100 per cent of Knotel's production stack is running on GraphQL, which includes some TypeScript, and a desire for more of it. Knotel is in the commercial real estate business and there's a lot of data about each of the properties where the biz has spaces, he said.
"When we were looking at designing front-end applications, they only needed a small subset of that data," he said. "Most of them need the address and the lat/long, for example. Sending back all the information we have about every building every time would be very, very onerous. And so for us, it made sense to use GraphQL where the client could select exactly what data they wanted to get back."
The company builds apps for internal usage, so employees can check on the condition of real estate spaces, as well as apps for customers that can unlock office doors and provide a way to report issues. It also has internal apps to help with the sales process, to show what spaces are available.
There's been a bit of a learning curve, Quinn said, but the benefit has been removing a lot of other complexity.
Quinn said the primary benefit of GraphQL has been the ability to revise the front end interfaces for the clients it has and the ability to develop applications based on the data graph more rapidly. ®
Read more about GraphQL on our devops sister site Devclass right here.
Sponsored: Beyond the Data Frontier