{"id":20355580,"url":"https://github.com/geekeast/type-graphql-playground","last_synced_at":"2026-05-17T01:49:06.201Z","repository":{"id":43372473,"uuid":"450689652","full_name":"GeekEast/type-graphql-playground","owner":"GeekEast","description":"Build a graphql server with type-graphql","archived":false,"fork":false,"pushed_at":"2022-03-04T20:47:47.000Z","size":1419,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-05T20:08:37.686Z","etag":null,"topics":["aggregation","class-transformer","class-validator","dataloader","mongoose","type-graphql","typedi"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GeekEast.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-22T01:40:33.000Z","updated_at":"2022-01-23T08:02:57.000Z","dependencies_parsed_at":"2022-09-13T19:22:21.646Z","dependency_job_id":null,"html_url":"https://github.com/GeekEast/type-graphql-playground","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/GeekEast/type-graphql-playground","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeekEast%2Ftype-graphql-playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeekEast%2Ftype-graphql-playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeekEast%2Ftype-graphql-playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeekEast%2Ftype-graphql-playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GeekEast","download_url":"https://codeload.github.com/GeekEast/type-graphql-playground/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeekEast%2Ftype-graphql-playground/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264734395,"owners_count":23655660,"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","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":["aggregation","class-transformer","class-validator","dataloader","mongoose","type-graphql","typedi"],"created_at":"2024-11-14T23:13:21.394Z","updated_at":"2026-05-17T01:49:01.133Z","avatar_url":"https://github.com/GeekEast.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# Type-graphql Playground\n  - [Kick off](#kick-off)\n  - [Graphql example](#graphql-example)\n  - [Regenerate Data](#regenerate-data)\n  - [Statistics](#statistics)\n  - [Next Phase](#next-phase)\n## Kick off\n```sh\n# install dependency\nyarn install\n\n# compose docker\nyarn project up\n\n# start graphql server\nyarn start\n```\n\n## Graphql example\n- query http://localhost:12305/graphql\n```graphql\nquery GetGroup($getGroupFilter: GetGroupDto!) {\n  GetGroup(filter: $getGroupFilter) {\n    _id\n    name\n    userCount\n  }\n}\n\n# query with datalodare loadMany() without aggregation help\nquery GetGroups($getGroupsFilter: GetGroupsDto!) {\n  GetGroups(filter: $getGroupsFilter) {\n    _id\n    name\n    userCount\n    users {\n      _id\n      email\n      firstName\n      lastName\n    }\n  }\n}\n\n# query with dataloader load() method with optmized mongo aggregation query\nquery GetGroupsViaSingleMongoQuery(\n  $getGroupsFilterViaSingleMongoQuery: GetGroupsDto!\n) {\n  GetGroups(filter: $getGroupsFilterViaSingleMongoQuery) {\n    _id\n    name\n    userCount\n    users2 {\n      _id\n      email\n      firstName\n      lastName\n    }\n  }\n}\n```\n- variables: ids is stored in generated `groupIds.json` in project root directory\n```json\n{\n  \"getGroupFilter\": {\n    \"_id\": \"61eabfc67d720e6372867487\"\n  },\n  \"getGroupsFilter\": {\n    \"_ids\": [\n      \"61eabfc67d720e6372867487\"\n    ]\n  },\n  \"getGroupsFilterViaSingleMongoQuery\": {\n    \"_ids\": [\n      \"61eabfc67d720e6372867487\"\n    ]\n  }\n}\n```\n\n## Regenerate Data\n```sh\n# generate the seed scripts\nyarn project generateSeedScripts\n\n# seed data to mongodb\nyarn project seed\n\n# create indices\nyarn project index\n```\n\n## Statistics\n- for query `2000` **groups** with **users**  as sub-document in graphql\n- dataloader has two main functionalities here: **batch** requests (deduplicate) and **cache** request (memory)\n- \n| Data Loader method  | Aggregation Query | Plain Query |  Time Consumed  | use case                            |\n| :-----------------: | :---------------: | :---------: | :-------------: | ----------------------------------- |\n|   `load(groupId)`   |        ✅         |             |  `600-1000ms`   | huge amount of fanned out promises  |\n| `loadMany(userIds)` |                   |     ✅      | `30000-60000ms` | small amount of fanned out promises |\n\n\n## Take away\n- Graphql **Flexibility**: Favor `field resolver` to assemble **exterior** fields over assembling in `service` layer.\n- Delegate **cumbersome** assembling logic from `field resolver` to mongodb `aggregate pipeline`.\n\n\n\n## Next Phase\n- How to do performant sorting in graphql layer since field resolver happens after data get fetched from database?","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeekeast%2Ftype-graphql-playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeekeast%2Ftype-graphql-playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeekeast%2Ftype-graphql-playground/lists"}