Apollo Connectors: Blazing-Fast Integration with REST APIs
Dylan Anthony
Apollo Connectors make it easier than ever to create a GraphQL API leveraging non-GraphQL services. Developers can use a declarative syntax, right in their schema files, to connect GraphQL fields to HTTP APIs. GraphOS Router uses that information to talk directly to the API, no subgraph needed.
Reducing complexity
Before today, when developers wanted to add a REST service to their federated GraphQL API, they had to take several steps:
- Identify a programming language and a Federation-compatible GraphQL framework
- Deploy a new subgraph service, including monitoring, auto-scaling, and load-balancing, which will sit in between the router and the REST API
- For each change to the REST API:
- Design the subgraph schema for the underlying REST data
- Write bindings to the REST API in the chosen programming language
- Write resolvers that leverage those bindings
- Deploy the subgraph service
- Compose and publish the schema to update the router
Apollo Connectors eliminate the need for the intermediate service, saving developer time and infrastructure cost. With connectors, each iteration is reduced to:
- Design the subgraph schema for the underlying REST data
- Compose and publish the schema to update the router
The router then speaks directly to the REST APIs:
Delighting developers
Apollo Connectors are designed with a singular goal in mind: make it as easy as possible for developers to build high-quality GraphQL APIs. Every aspect was built from the ground up to achieve this goal, starting with the declarative syntax:
type Query {
post(id: ID!): Post
@connect(
source: "rest_api_v1"
http: { GET: "/posts/{$args.id}" }
selection: """
id
title
body
author: { id: userId }
"""
)
}
Data sources are connected right in your schema, so there’s no need to hop back and forth between multiple files. The selection format, for transforming the data, is designed to feel like the GraphQL query language to reduce context switching. It’s also designed to provide as much feedback as possible early in the development lifecycle, especially when combined with our Visual Studio Code extension. No more catching typos after deploy:
Our focus on developers extends through the testing phase, with powerful new debugging tools built into Apollo Sandbox:
And, of course, you get the production-ready features you’ve come to expect from GraphOS Router, like in-depth observability, built on the OpenTelemetry standard:
Get connected
Apollo is on a journey to make developing, operating, and consuming APIs as delightful as possible. GraphQL is a developer-friendly abstraction over all the moving pieces of modern applications. Apollo Connectors make the process of tying those pieces together into a cohesive, well-crafted schema, better than ever. You can try out connectors today with your existing Enterprise plan or by getting started with GraphOS for free. Send us your feedback and ask questions in our forums or Discord server. We can’t wait to see what you create!