Home / Companies / Apollo / Blog / Post Details
Content Deep Dive

Easy and performant GraphQL over REST

Blog post from Apollo

Post Details
Company
Date Published
Author
Martijn Walraven
Word Count
1,180
Language
English
Hacker News Points
-
Summary

Data sources is a new feature in Apollo Server 2.0 that allows teams to fetch and cache data from REST endpoints, replacing the need for DataLoader. Data sources are classes that encapsulate fetching data from a particular service with built-in support for caching, deduplication, and error handling. They provide a straightforward way to load data from REST APIs without having to write custom code. Data sources allow teams to intercept fetches to set headers or make other changes to the outgoing request, making it ideal for authorization. Apollo Server will then put the data sources on the context for every request, so they can be accessed by resolvers. This approach provides a low-friction path to rolling out GraphQL and complements existing investments in microservices and infrastructure. Data sources also enable partial query caching, which is valuable in a GraphQL server because it unlocks the ability to cache responses from underlying APIs and assemble them into arbitrary query results without refetching from the server.