feat(graphql): 由 Vercel Serverless function 驱动的 GraphQL API#28
Open
ANGJustinl wants to merge 19 commits intodatawhalechina:mainfrom
Open
feat(graphql): 由 Vercel Serverless function 驱动的 GraphQL API#28ANGJustinl wants to merge 19 commits intodatawhalechina:mainfrom
ANGJustinl wants to merge 19 commits intodatawhalechina:mainfrom
Conversation
- Add GraphQL schema definition with Member, DomainStat, Leaderboard, and ProjectInfo types - Implement DataSource module for data loading and caching from static JSON files - Create Resolvers module with filtering, sorting, pagination, and leaderboard calculation logic - Add GraphQL Client with convenient JavaScript API methods for common queries - Implement 5 leaderboard algorithms: popularity, productivity, social, rising star, and comprehensive - Add comprehensive GraphQL API documentation with architecture overview and usage examples - Create GraphQLDemo Vue component for interactive API demonstrations - Update VitePress config to include GraphQL API navigation link - Add graphql and graphql-js dependencies to package.json - Enable frontend-only GraphQL queries without requiring backend server
- Add graphql ^16.8.1 as a new dependency - Update mdast-util-to-hast from 13.2.0 to 13.2.1 - Update preact from 10.27.1 to 10.28.2 - Update vite from 5.4.20 to 5.4.21 - Remove peer dependency flags from @algolia/client-search, algoliasearch, echarts, focus-trap, and vue - Resolve dependency conflicts and ensure compatibility with GraphQL API implementation
Simplify .gitignore and remove diff.txt
Update daily-data-update.yml
Update bot_filter.py
…ation * 'main' of https://github.com/ANGJustinl/members-visualization: (69 commits) 🤖 Auto-update member data and avatars - 2026-02-11 22:29:59 UTC 🤖 Auto-update member data and avatars - 2026-02-10 22:41:18 UTC Update bot_filter.py 🤖 Auto-update member data and avatars - 2026-02-09 22:36:08 UTC 📊 Update quarterly contributors data - 2026-02-09 07:26:43 UTC Update daily-data-update.yml 🤖 Auto-update member data and avatars - 2026-02-08 22:27:24 UTC 🤖 Auto-update member data and avatars - 2026-02-07 22:26:27 UTC 🤖 Auto-update member data and avatars - 2026-02-06 22:26:39 UTC 📊 Update quarterly contributors data - 2026-02-06 17:31:56 UTC Simplify .gitignore and remove diff.txt 📊 Update quarterly contributors data - 2026-02-06 10:09:05 UTC Update quarterly-contributors.yml 📊 Update quarterly contributors data - 2026-02-06 09:51:12 UTC Update README.md Update index.md Update quarterly-contributors.yml 📊 Update quarterly contributors data - 2026-02-06 08:45:23 UTC Limit workflow add, move cache, skip bots Update QuarterlyContributors.vue ...
…ironment configuration.
… documentation - Deleted the GraphQL schema definition file to streamline the project structure. - Introduced a new API documentation file detailing the GraphQL API features, usage, and query examples. - Updated existing documentation to reflect changes in the API structure and usage patterns.
Author
[Edit Require] 文档中调用示例部分还需要改为实际的url |
4 tasks
This comment was marked as duplicate.
This comment was marked as duplicate.
There was a problem hiding this comment.
Pull request overview
该 PR 将原本的 GraphQL 能力调整为由 Vercel Serverless Function 提供的后端 API(/api/graphql),并同步更新前端调用方式与文档入口/路径,以适配 Vercel 部署与本地 vercel dev 调试流程。
Changes:
- 新增 Vercel 部署配置(
vercel.json),并加入 Serverless Function 的运行时配置。 - 新增 Serverless GraphQL API(schema/resolvers/dataSource + handler),前端 GraphQL client 改为
fetch('/api/graphql')调用。 - 调整/新增 GraphQL API 文档路径与站点导航入口(迁移到
/api/docs)。
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| vercel.json | 配置 Vercel 的 VitePress 构建输出与函数超时等参数 |
| package.json | 增加 graphql 依赖以支持后端 schema 执行 |
| package-lock.json | 锁文件更新以反映依赖变更 |
| docs/.vitepress/config.mjs | 增加对 VERCEL 环境的 base 路径判断,并调整 API 文档入口位置 |
| docs/api/docs.md | 新增(或迁移后的)GraphQL API 文档页面(目标路径 /api/docs) |
| docs/graphql-api.md | 新增根目录的 GraphQL 文档页(与“迁移到 /api/docs”的目标存在重叠) |
| docs/.vitepress/graphql/client.js | 新增 fetch-based GraphQL 客户端封装与便捷查询方法 |
| docs/.vitepress/graphql/index.js | GraphQL 客户端入口导出文件 |
| docs/.vitepress/graphql/README.md | GraphQL 相关实现说明文档 |
| docs/.vitepress/theme/graphql-demo/GraphQLDemo.vue | GraphQL 查询演示组件(UI + 调用 client) |
| api/package.json | 将 api/ 目录设为 ESM 并声明函数依赖 |
| api/graphql.js | Vercel Serverless Function:GraphQL handler + GraphiQL + CORS |
| api/_lib/schema.js | GraphQL schema(GraphQL.js)定义 |
| api/_lib/resolvers.js | GraphQL resolvers 业务逻辑实现 |
| api/_lib/dataSource.js | Serverless 侧数据加载与缓存逻辑(从静态数据源 fetch) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
API 文档参见: https://members-visualization.vercel.app/api/docs
Playground位于: https://members-visualization.vercel.app/api/graphql
描述
1. ♻️ 创建 GraphQL API 架构
/api/graphql)。fetch请求后端 API。2. 📝 文档结构调整
/api/docs,降低对普通用户的干扰。curl/fetch/Python 的调用示例。部署相关 (后端部分需要部署Vercel平台)
关于 Vercel 部署
无需额外配置,只需将代码合并至
main分支。Vercel 会自动读取 vercel.json 和 api 目录进行部署。VERCEL=1会被构建脚本自动识别,从而正确设置网站根路径。关于本地开发
由于 API 现在的运行依赖于 Serverless Function 环境,在本地开发时如果需要调试 API 相关功能,建议使用 Vercel CLI:
如果直接运行
npm run docs:dev,页面浏览正常,但涉及 GraphQL 的数据请求可能会因为没有后端环境而失败(除非配置了代理)。Check List