Apollo connector for MongoDB, version 3.1.1, providing seamless integration with GraphQL (Apollo). It facilitates MongoDB connection, result caching via Facebook's DataLoader for batch processing and caching, and unit testing with a handy `withEntity` function. Built in ES6 with CommonJS modules, requires Node 6+. Key differentiators include built-in caching for database queries and easy unit testing support, distinguishing it from raw MongoDB drivers or other GraphQL connectors. Release cadence appears low, with maintenance mode likely.
npm install apollo-connector-mongodbNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create a MongoConnector and MongoEntity, set up caching with lru-cache, and use findOneCachedById.
Update code to use cursor-based access or call .toArray(). Check mongodb 4.0 migration guide.
If using Node 16+, consider using a more modern driver such as 'mongodb' directly or a GraphQL datasource.
Always pass a cacheMap (e.g., lru-cache) to MongoEntity constructor for caching to function.
Use environment variables or a test MongoDB instance (e.g., mongod in-memory) to avoid polluting dev databases.
Consider migrating to a maintained alternative such as 'datasource-mongodb' or using the MongoDB driver directly.
Ensure MongoConnector callback is invoked after successful connection, and check MongoDB URI.
Run 'npm install apollo-connector-mongodb' and ensure correct import syntax.
Install dataloader: 'npm install dataloader'.
Import lru-cache: 'import lruCache from 'lru-cache';'