{"id":24862559,"url":"https://github.com/riii111/fastapi-graphql-sample","last_synced_at":"2026-01-29T14:10:49.785Z","repository":{"id":258106968,"uuid":"871490461","full_name":"riii111/fastapi-graphql-sample","owner":"riii111","description":"技術検証用。FastAPIにGraphQL導入","archived":false,"fork":false,"pushed_at":"2024-11-17T08:27:31.000Z","size":339,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T23:51:22.677Z","etag":null,"topics":["fastapi","graphql","mongodb","python"],"latest_commit_sha":null,"homepage":"","language":"Python","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/riii111.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":"2024-10-12T05:34:32.000Z","updated_at":"2024-11-21T10:25:42.000Z","dependencies_parsed_at":"2025-03-26T17:44:47.230Z","dependency_job_id":null,"html_url":"https://github.com/riii111/fastapi-graphql-sample","commit_stats":null,"previous_names":["riii111/fastapi-nuxt3-graphql-sample","riii111/fastapi-graphql-sample"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/riii111/fastapi-graphql-sample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riii111%2Ffastapi-graphql-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riii111%2Ffastapi-graphql-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riii111%2Ffastapi-graphql-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riii111%2Ffastapi-graphql-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riii111","download_url":"https://codeload.github.com/riii111/fastapi-graphql-sample/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riii111%2Ffastapi-graphql-sample/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28879051,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T10:31:27.438Z","status":"ssl_error","status_checked_at":"2026-01-29T10:31:01.017Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["fastapi","graphql","mongodb","python"],"created_at":"2025-01-31T22:58:00.963Z","updated_at":"2026-01-29T14:10:49.755Z","avatar_url":"https://github.com/riii111.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"※RESTとGraphQLを併用できる形で実装。\n\n# GraphQL memo\n\n## GUI\n\n\u003chttp://localhost:30020/graphql\u003e\n\n## GraphQLのフロー\n\nGraphQL、REST併用することを想定しているので、usecaseやmodel、repositoryを経由する。\n\"Book\"に対してQuery/Mutationを行う場合のフロー。\n\n```mermaid\ngraph TD\n    Client[Client] --\u003e|GraphQL Query| Router[GraphQL Router]\n    Router --\u003e|Executes| Schema[\"Federation Schema (Query)\"]\n    Schema --\u003e|Defines \u0026 Resolves| Query[Query]\n    Query --\u003e|Resolves| Resolvers[Resolvers]\n    Resolvers --\u003e|Uses| Context[GraphQL Context]\n    Context --\u003e|Depends on| BookUseCase[Book UseCase]\n    BookUseCase --\u003e|Uses| BookRepository[Book Repository]\n    BookRepository --\u003e|Accesses| Database[(Database)]\n    \n    Resolvers --\u003e|Returns| BookType[BookType]\n    BookType --\u003e|Defined in| Types[Types]\n    Types --\u003e|Uses| PyObjectIdType[PyObjectIdType]\n    \n    subgraph \"GraphQL Layer\"\n        Router\n        Schema\n        Query\n        Resolvers\n        Context\n        BookType\n        Types\n        PyObjectIdType\n    end\n    \n    subgraph \"Business Logic Layer\"\n        BookUseCase\n    end\n    \n    subgraph \"Data Access Layer\"\n        BookRepository\n    end\n    \n    subgraph \"Models\"\n        Book[Book Model]\n        PyObjectId[PyObjectId Model]\n    end\n    \n    BookType -.-\u003e|Maps to| BookResponse\n    PyObjectIdType -.-\u003e|Serializes| PyObjectId\n    \n    classDef graphql fill:#e6f3ff,stroke:#333,stroke-width:2px,color:#000;\n    classDef business fill:#fff2cc,stroke:#333,stroke-width:2px,color:#000;\n    classDef data fill:#e6ffee,stroke:#333,stroke-width:2px,color:#000;\n    classDef model fill:#ffe6e6,stroke:#333,stroke-width:2px,color:#000;\n    \n    class Router,Schema,Query,Resolvers,Context,BookType,Types,PyObjectIdType graphql;\n    class BookUseCase business;\n    class BookRepository data;\n    class BookResponse,PyObjectId model;\n\n    linkStyle default fill:none,stroke:#333,stroke-width:2px;\n```\n\n## 動作確認例\n\n### books一覧を取得する場合\n\n\u003cimg width=\"1624\" alt=\"image\" src=\"https://github.com/user-attachments/assets/af6b548b-5149-4a97-9c49-8c2b69660ed3\"\u003e\n\n### 対象のIDのbookを取得する場合\n\n\u003cimg width=\"1624\" alt=\"image\" src=\"https://github.com/user-attachments/assets/15f82b11-168d-44f5-a8d4-7b2a467c6a47\"\u003e\n\n### 新しいbookを作成する場合\n\n\u003cimg width=\"1624\" alt=\"image\" src=\"https://github.com/user-attachments/assets/b2219d06-bfc6-414f-b9e0-58e6bb9a2825\"\u003e\n\n### bookを更新する場合\n\n\u003cimg width=\"1624\" alt=\"image\" src=\"https://github.com/user-attachments/assets/042a7a61-4e26-45d1-8f71-88713a61bc5f\"\u003e\n\n### bookを削除する場合\n\n\u003cimg width=\"1624\" alt=\"image\" src=\"https://github.com/user-attachments/assets/41597ad8-61bd-456e-98d4-8c9463c4b66b\"\u003e\n\n## ざっくりメモ\n\n- **クエリ (Query)**\u003cbr/\u003e\n  データを取得するためのリクエスト\u003cbr/\u003e\n  クライアントが必要なデータの構造を指定し、その構造に基づいてサーバーからデータが返される\n\n- **ミューテーション (Mutation)**\u003cbr/\u003e\n  データを変更するためのリクエスト\u003cbr/\u003e\n  新しいデータの作成、既存データの更新、削除などが含まれる\n\n- **サブスクリプション (Subscription)**\u003cbr/\u003e\n  特定のイベントが発生した際に、クライアントにリアルタイムで通知を送信する仕組み\u003cbr/\u003e\n  主にチャットアプリや通知機能で利用される\n\n- **スキーマ (Schema)**\u003cbr/\u003e\n  GraphQL APIの仕様を定義するもの\u003cbr/\u003e\n  どのようなデータ型が存在し、それらがどのように関連しているかを示す\u003cbr/\u003e\n  スキーマは型システムに基づいており、APIの設計を明確にする\n\n- **型 (Type)**\u003cbr/\u003e\n  GraphQLで使用されるデータ型\u003cbr/\u003e\n  基本的なスカラー型（String, Int, Float, Boolean, ID）やオブジェクト型などがある\n\n- **リゾルバ (Resolver)**\u003cbr/\u003e\n  特定のフィールドに対してデータを取得するための関数\u003cbr/\u003e\n  リゾルバはスキーマで定義されたフィールドに基づいて実行される\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friii111%2Ffastapi-graphql-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friii111%2Ffastapi-graphql-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friii111%2Ffastapi-graphql-sample/lists"}