apollo-datasource-mongodb icon indicating copy to clipboard operation
apollo-datasource-mongodb copied to clipboard

mongodb should be a dependency or peerDependency instead of devDependency

Open crccheck opened this issue 3 years ago • 2 comments

In /src/cache, dataloader and bson are dependencies, but mongodb is not: https://github.com/GraphQLGuide/apollo-datasource-mongodb/blob/08e1c076739867a9e73a707adc66767a7e8525d7/src/cache.js#L1-L3

Current dependencies: https://github.com/GraphQLGuide/apollo-datasource-mongodb/blob/5d8f93a141ba7fdd85c0dbd86e8290380603c667/package.json#L19-L26

That means if you install apollo-datasource-mongodb, then run npm prune --production, there's a chance that the mongodb package will be pruned and this package will error with:

Error: Cannot find module 'mongodb'

crccheck avatar Jun 09 '22 15:06 crccheck

what's strange is I have mongoose as a dependency, so I should be getting mongodb via that: https://github.com/Automattic/mongoose/blob/b0043b7be02f846bb224e2332be0867aec058904/package.json#L24

edit: I had mongoose which wanted [email protected] and mongodb-memory-server which wanted mongodb@^4.5.0, which resolved to v4.7.0. So when my build process ran npm prune, it deleted node_modules/mongodb as it should have and my error happened

crccheck avatar Jun 09 '22 16:06 crccheck

peerDependency sounds good, PR welcome

lorensr avatar Oct 08 '22 22:10 lorensr