A library for creating Apollo DataSources that connect to an existing GraphQL API. Current version is 1.3.2. It provides a simple way to integrate external GraphQL services into Apollo Server, similar to RESTDataSource but for GraphQL. Key differentiator: allows using Apollo Server's data source layer with GraphQL APIs, enabling caching, deduplication, and error handling. It is designed for Apollo Server 2.0 and uses GraphQL queries/mutations to fetch data. Note that this project is not actively maintained and has limited test coverage.
npm install apollo-datasource-graphqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Defines a GraphQLDataSource subclass that connects to an external GraphQL API, sets auth headers, and runs a query.
Consider forking the repository or using RESTDataSource if possible.
Use import syntax or ensure your project is also ESM.
Set baseURL without trailing slash, e.g., 'https://api.example.com/graphql'.
Add guard: if (!request.headers) request.headers = {};Run 'npm install apollo-datasource-graphql' and verify import path
Ensure willSendRequest checks for context: if (this.context && this.context.token) { request.headers.authorization = this.context.token; }Ensure the first argument is a parsed GraphQL document: const query = gql`...`; then this.query(query)