GraphQL 是一种现代化的查询语言,专为 API 开发设计,允许客户端精确获取所需数据。以下是关键使用步骤:
安装依赖
npm install graphql express
定义 Schema
type Query { hello: String }
创建 Resolver
const resolvers = { Query: { hello: () => 'World' } };
执行查询
query { hello }
如需深入学习,可访问 GraphQL 教程 或查阅 API 文档。