{"id":16439630,"url":"https://github.com/sevenoutman/apollo-practice","last_synced_at":"2025-02-25T22:28:23.877Z","repository":{"id":210382103,"uuid":"717029266","full_name":"SevenOutman/apollo-practice","owner":"SevenOutman","description":"Practice of using Apollo Server as a BFF that aggregates various backend services.","archived":false,"fork":false,"pushed_at":"2023-12-28T16:26:03.000Z","size":1812,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-08T11:24:00.667Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://apollo-practice-frontend.vercel.app","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/SevenOutman.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-10T11:53:59.000Z","updated_at":"2025-01-04T14:59:00.000Z","dependencies_parsed_at":"2023-12-09T06:22:25.460Z","dependency_job_id":"915b3c8b-aab0-4bd8-937a-271fcedba92d","html_url":"https://github.com/SevenOutman/apollo-practice","commit_stats":null,"previous_names":["sevenoutman/apollo-practice"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SevenOutman%2Fapollo-practice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SevenOutman%2Fapollo-practice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SevenOutman%2Fapollo-practice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SevenOutman%2Fapollo-practice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SevenOutman","download_url":"https://codeload.github.com/SevenOutman/apollo-practice/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240757785,"owners_count":19852820,"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":[],"created_at":"2024-10-11T09:09:57.568Z","updated_at":"2025-02-25T22:28:23.838Z","avatar_url":"https://github.com/SevenOutman.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Apollo practice\n\nThis repo is a practice of using Apollo Server as a BFF that aggregates various backend services.\n\n## Practices\n\n- GraphQL -\u003e TypeScript codegen (both client and server)\n- Data sources (REST, gRPC, JSON RPC)\n- JWT-based authentication\n- Logging\n- Plugins\n- Tracing\n\n## Architecture\n\n```mermaid\n  graph LR;\n\n      subgraph Domestic\n        frontend[Frontend] -- GraphQL --\u003ebff[BFF]\n        bff-- JSON RPC --\u003euser-service[\"User service\"]\n        bff-- gRPC --\u003epost-service[\"Post service\"]\n      end\n\n      subgraph thrid-party[Third-party services]\n        jsonplaceholder\n      end\n\n      bff-- REST API --\u003ejsonplaceholder[JSONPlaceholder]\n      user-service-- REST API --\u003ejsonplaceholder\n      post-service-- REST API --\u003ejsonplaceholder\n```\n\n## Logging\n\nLogging is done with Winston in a whitelist manner (implemented as a custom format).\nOnly registered messages are logged.\n\n```ts\nimport { logger, messages } from \"./logging\";\n\nlogger.info(messages.info.serverStarted(url)); // info: Server started at http://localhost:4000\n\nlogger.info(\"Server started\"); // info: Unregistered \"info\" level message\n```\n\n## Tracing\n\nTracing is reported in OpenTelemetry format to a local Jaeger instance.\n\nComponents with tracing include:\n\n- BFF (incoming GraphQL requests, outgoing JSON RPC calls, outgoing gRPC calls)\n- User service (incoming JSON RPC calls, outgoing REST API calls)\n- Post service (incoming JSON RPC calls, outgoing REST API calls)\n\nAn example trace:\n\n![Screenshot of Jaeger UI](./trace.png)\n\n## TODO\n\n- [ ] Authentication \u0026 authorization\n- [ ] Figure out whether `ID` could be a number\n\n## Run locally\n\nInstall dependencies:\n\n```sh\npnpm i\n```\n\nStart user-service and post-service:\n\n```sh\npnpm --filter=user-service dev\npnpm --filter=post-service dev\n```\n\nStart BFF and frontend:\n\n```sh\npnpm --filter=backend dev\npnpm --filter=frontend dev\n```\n\nStart a Jaeger instance:\n\n```sh\ndocker run --rm --name jaeger \\\n-e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \\\n-p 6831:6831/udp \\\n-p 6832:6832/udp \\\n-p 5778:5778 \\\n-p 16686:16686 \\\n-p 4317:4317 \\\n-p 4318:4318 \\\n-p 14250:14250 \\\n-p 14268:14268 \\\n-p 14269:14269 \\\n-p 9411:9411 \\\njaegertracing/all-in-one:1.51\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsevenoutman%2Fapollo-practice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsevenoutman%2Fapollo-practice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsevenoutman%2Fapollo-practice/lists"}