{"id":42806,"library":"graphql-anywhere-mongodb","title":"graphql-anywhere-mongodb","description":"An experimental library that bridges GraphQL queries to MongoDB collections using graphql-anywhere. Version 0.5.2 is the latest and only stable release. It allows querying MongoDB with GraphQL syntax, supporting projections, filtering (eq, gte, gt, etc.), pagination (limit/skip), sorting via @sort/@sortDesc directives, and multiple collections per query. Key differentiator: schemaless querying without defining a GraphQL schema upfront. However, it is explicitly marked as not production-ready and has no recent updates since 2017. Use with caution for prototyping only.","status":"deprecated","version":"0.5.2","language":"javascript","source_language":"en","source_url":"https://github.com/dflor003/graphql-anywhere-mongodb","tags":["javascript","graphql","anywhere","graphql-anywhere","mongo","mongodb","typescript"],"install":[{"cmd":"npm install graphql-anywhere-mongodb","lang":"bash","label":"npm"},{"cmd":"yarn add graphql-anywhere-mongodb","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql-anywhere-mongodb","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for parsing GraphQL queries using the gql template literal.","package":"graphql-tag","optional":false},{"reason":"Core dependency providing the graphql-anywhere infrastructure for custom resolvers.","package":"graphql-anywhere","optional":false},{"reason":"Native MongoDB driver for connection and query execution.","package":"mongodb","optional":false}],"imports":[{"note":"Default import is the only way; named exports are not available. ESM-only, no CJS support.","wrong":"import graphql from 'graphql-anywhere-mongodb'","symbol":"default","correct":"import graphql from 'graphql-anywhere-mongodb'"},{"note":"forUri returns a promise; must be awaited or chained with .then().","wrong":"const mongo = graphql.forUri('mongodb://...')","symbol":"forUri","correct":"const mongo = await graphql.forUri('mongodb://...')"},{"note":"forConnection expects a MongoDB Db instance, not a URI string.","wrong":"const mongo = graphql.forConnection('mongodb://...')","symbol":"forConnection","correct":"const mongo = graphql.forConnection(existingDbConnection)"}],"quickstart":{"code":"import graphql from 'graphql-anywhere-mongodb';\nimport gql from 'graphql-tag';\n\nasync function main() {\n  const mongo = await graphql.forUri(process.env.MONGO_URI ?? 'mongodb://localhost:27017/mydb');\n  const query = gql`\n    {\n      users (limit: 10) {\n        firstName\n        lastName\n        age (gte: 21)\n      }\n    }\n  `;\n  const results = await mongo.find(query, {});\n  console.log(results);\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Connects to MongoDB, executes a GraphQL query on the 'users' collection with limit and filter, then prints results."},"warnings":[{"fix":"Consider using an alternative like graphql-compose-mongoose or PostGraphile for production.","message":"This library is marked as experimental and not recommended for production use.","severity":"deprecated","affected_versions":">0.0.0"},{"fix":"Use import graphql from 'graphql-anywhere-mongodb' and then call graphql.forUri().","message":"Imports must be the default import; named imports (e.g., import { forUri }) will fail.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always use await: const mongo = await graphql.forUri(...).","message":"forUri() returns a Promise; must be awaited or used with .then() to get the executor.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use ES modules and import syntax. If you need CJS, stick to v0.4.x or transpile.","message":"Since v0.5.0, the library switched to ESM-only; CommonJS require() will not work.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Be aware that _id is always included in results; filter if needed.","message":"The MongoDB _id field is always returned regardless of the GraphQL query projection.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.5.2':20 '2017':80 'allow':29 'anywher':3,18,89,92 'bridg':9 'caution':83 'collect':14,51 'defin':59 'differenti':55 'direct':48 'eq':38 'etc':41 'experiment':6 'explicit':67 'filter':37 'graphql':2,10,17,33,61,88,91 'graphql-anywher':16,90 'graphql-anywhere-mongodb':1 'gt':40 'gte':39 'howev':64 'javascript':87 'key':54 'latest':23 'librari':7 'limit/skip':43 'mark':68 'mongo':93 'mongodb':4,13,31,94 'multipl':50 'pagin':42 'per':52 'product':72 'production-readi':71 'project':36 'prototyp':85 'queri':11,30,53,57 'readi':73 'recent':77 'releas':27 'schema':62 'schemaless':56 'sinc':79 'sort':44,46 'sortdesc':47 'stabl':26 'support':35 'syntax':34 'typescript':95 'updat':78 'upfront':63 'use':15,81 'version':19 'via':45 'without':58","created_at":"2026-06-05T16:56:45.927607+00:00","updated_at":"2026-06-05T16:56:45.927607+00:00","problems":[{"fix":"Replace import { forUri } from 'graphql-anywhere-mongodb' with import graphql from 'graphql-anywhere-mongodb'.","cause":"Incorrect import: using named import instead of default import.","error":"graphql.forUri is not a function"},{"fix":"Use await: const mongo = await graphql.forUri(...).","cause":"forUri returns a Promise not caught properly.","error":"TypeError: graphql.forUri(...) is undefined"},{"fix":"Install the peer dependency: npm install graphql-anywhere.","cause":"Peer dependency graphql-anywhere is missing.","error":"Cannot find module 'graphql-anywhere'"},{"fix":"Use mongodb native driver instead of mongoose.","cause":"This error is from mongoose, not this library. Ensure you are using native MongoDB driver, not Mongoose.","error":"MissingSchemaError: Schema hasn't been registered for model \"users\""}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/dflor003/graphql-anywhere-mongodb#readme","github":"https://github.com/dflor003/graphql-anywhere-mongodb","docs":null,"changelog":null,"pypi":null,"npm":"graphql-anywhere-mongodb","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}