{"id":28494269,"url":"https://github.com/recodive/mongodatasource","last_synced_at":"2025-08-16T18:09:55.581Z","repository":{"id":37815828,"uuid":"422910077","full_name":"Recodive/MongoDataSource","owner":"Recodive","description":"An Apollo GraphQL Datasource using MongoDB.","archived":false,"fork":false,"pushed_at":"2023-12-15T05:09:12.000Z","size":77,"stargazers_count":3,"open_issues_count":7,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-09T01:34:45.957Z","etag":null,"topics":["apollo","mongodb","nodejs","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Recodive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-10-30T14:52:40.000Z","updated_at":"2023-09-04T11:58:09.000Z","dependencies_parsed_at":"2023-12-15T06:26:31.684Z","dependency_job_id":null,"html_url":"https://github.com/Recodive/MongoDataSource","commit_stats":{"total_commits":27,"total_committers":4,"mean_commits":6.75,"dds":0.6296296296296297,"last_synced_commit":"5d38923fea520f40ec53a5940d00061b940131dc"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/Recodive/MongoDataSource","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Recodive%2FMongoDataSource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Recodive%2FMongoDataSource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Recodive%2FMongoDataSource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Recodive%2FMongoDataSource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Recodive","download_url":"https://codeload.github.com/Recodive/MongoDataSource/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Recodive%2FMongoDataSource/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270749484,"owners_count":24638747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apollo","mongodb","nodejs","typescript"],"created_at":"2025-06-08T10:05:45.282Z","updated_at":"2025-08-16T18:09:55.568Z","avatar_url":"https://github.com/Recodive.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MongoDataSource\n\nAn Apollo GraphQL Datasource using MongoDB.\n\n## Why\n\nWhile there already is a somewhat good MongoDB DataSource package available ([apollo-datasource-mongodb](https://github.com/GraphQLGuide/apollo-datasource-mongodb)), it still lacks some features / functions that we needed in our projects, while it doesn't _yet_ support the main feature of the existing package ([Batching](https://github.com/GraphQLGuide/apollo-datasource-mongodb#batching)), it fixes other small issues like the prevention of spamming MongoDB with requests when there's already a query running for it.\n\nThis DataSource is currently in use by [PreMiD/API](https://github.com/PreMiD/API) at a large scale.\n\n## Installation\n\n```Shell\n# NPM\nnpm i apollo-mongodb-datasource\n\n# YARN\nyarn add apollo-mongodb-datasource\n```\n\n## Usage\n\n### TypeScript\n\nindex.ts\n\n```TS\nimport { MongoClient } from 'mongodb'\n\nimport Users from './dataSources/Users'\n\nconst client = new MongoClient('mongodb://localhost:27017/test');\nclient.connect()\n\nconst server = new ApolloServer({\n  typeDefs,\n  resolvers,\n  dataSources: () =\u003e ({\n    users: new Users(client.db().collection('users'))\n  })\n})\n```\n\nUsers.ts\n\n```TS\nimport MongoDataSource from 'apollo-mongodb-datasource'\n\nexport default class Users extends MongoDataSource {\n  getUser(userId: string) {\n    return this.findOne({userId})\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecodive%2Fmongodatasource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frecodive%2Fmongodatasource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecodive%2Fmongodatasource/lists"}