@cap-js/graphql

中文文档
0.14.0发布于 2025/10/24Apache-2.0CommonJS近 30 天下载 5842

CDS protocol adapter for GraphQL

原始使用文档
文档目录6 节
  1. About this project
  2. Requirements and Setup
  3. Limitations
  4. Support, Feedback, Contributing
  5. Code of Conduct
  6. Licensing

REUSE status

CDS protocol adapter for GraphQL

About this project

A GraphQL protocol adapter for SAP Cloud Application Programming Model Node.js. This adapter generically generates a GraphQL schema for the models of an application and serves an endpoint that allows you to query your services using the GraphQL query language.

WARNING: This package is in an early general availability state. This means that it is generally available, with stable APIs unless otherwise indicated, and you can use it for production. However, please note the current limitations listed below.

Requirements and Setup

  1. Simply add the GraphQL adapter to your project using npm:
    npm add @cap-js/graphql
    

This command will set up the GraphQL plug-in with the @sap/cds runtime. It enables the new middlewares architecture in Node.js and registers a GraphQL endpoint at /graphql serving all CRUD requests for the application services found in your model.

  1. Annotate the services you want to serve, e.g. using @graphql or @protocol: 'graphql'.

  2. Run your server as usual, e.g. using cds watch.

The runtime will serve all annotated services via GraphQL at the default configured endpoint.

Limitations

  • Actions and functions are not yet supported.
  • CDS annotations like @readonly aren’t considered during schema generation.
  • Cursor-based Pagination – we currently support offset-based pagination, and will add cursor-based pagination going forward. While we intend to support both variants then, it is not guaranteed that we can do so without breaking changes to current behaviour.
  • Extensions are not yet considered.

Support, Feedback, Contributing

This project is open to feature requests/suggestions, bug reports etc. via GitHub issues. Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our Contribution Guidelines.

Code of Conduct

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its Code of Conduct at all times.

Licensing

Copyright 2022 SAP SE or an SAP affiliate company and cap-js/graphql contributors. Please see our LICENSE for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via the REUSE tool.

版本与发布记录

@cap-js/graphql 共发布 19 个版本,首次发布于 2022/12/08;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.14.0latest2025/10/241 年前
0.13.02025/07/111.3 年前
0.12.0next2025/05/051.5 年前
0.11.02024/07/302 年前
0.10.12024/03/072 年前
0.10.02024/01/302 年前

关于 @cap-js/graphql 的常见问题

@cap-js/graphql 是什么?

CDS protocol adapter for GraphQL

如何安装 @cap-js/graphql?

在项目目录运行 npm install @cap-js/graphql,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@sap/cds(>=9)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cap-js/graphql 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cap-js__graphql 是否存在。

@cap-js/graphql 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@cap-js/graphql 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cap-js/graphql 可以商用吗?

@cap-js/graphql 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@cap-js/graphql 的下载量有多少?

根据 npm 官方下载统计,@cap-js/graphql 在 2026/10/09 – 2026/11/07 这 30 天内被下载 5,842 次,日均约 195 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cap-js/graphql 还在维护吗?

最新版本 0.14.0 发布于 2025/10/24(1 年前);至今共发布 19 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/12/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。