A library that generates MongoDB query filters, projections, and sort/pagination arguments from GraphQL types at runtime. Version 1.6.5, last updated in 2023, with no active release cadence. It provides helper functions like getGraphQLQueryArgs and getMongoDbQueryResolver to automatically create input filter types and resolve them into MongoDb find operations. Unlike code-first ORMs, it works with existing GraphQL schema types and supports nested field filtering, logical operators (AND, OR, NOR), and sort/pagination. Requires graphql >=14.2.1. Ships TypeScript definitions.
npm install graphql-to-mongodbNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a GraphQL query that uses auto-generated filter and sort args, then resolves with MongoDB find.
Use db.collection('people').find(filter, options) instead of .find(filter, projection, options).Add dependencies: ['name'] or specific nested fields to the field definition.
Consider forking or using alternatives like graphql-compose-mongoose for active support.
Run npm install graphql-to-mongodb --save and ensure import uses ES module syntax.
Use import { getMongoDbQueryResolver } from 'graphql-to-mongodb'.Ensure filter keys match the auto-generated filter type exactly (case-sensitive).