Skip to Content
Technical Articles
Author's profile photo Jhodel Cailan

CAP: GraphQL as new protocol

I’ve been looking into SAP Graph and GraphQL for quite some time now, and out of curiosity, I tried to look into CAP if it already supports GraphQL, and lucky enough CAP just recently started supporting GraphQL by releasing¬†@cap-js/graphql which acts as a GraphQL adapter.

In this blog post, I will be giving a quick introduction to GraphQL in CAP.



Set up GraphQL adapter

Technically the adapter is very easy to set up. It is very straightforward to follow the instructions mentioned in the @cap-js/graphql node module, but for the sake of completeness, I will mention it here as well.

  • Add the GraphQL adapter to your CAP project:
> npm install @cap-js/graphql
NOTE: The adapter is relatively new (3 months old at the time this blog post is written) so make sure your cap node modules are up to date – @sap/cds and @sap/cds-dk.
  • Register GraphQL adapter in your projects package.json:
  "cds": {
    "protocols": {
      "graphql": { "path": "/graphql", "impl": "@cap-js/graphql" }


Testing the GraphQL endpoint

Run the CAP application as usual using cds watch terminal command and the GraphQL endpoint will be available at:

  • Testing via the built-in GraphiQL client

  • Testing via Postman client

I’m sharing here my CAP project if you want to follow exactly the testing samples I provided above:



GraphQL protocol is very much a welcome addition to the already formidable features offered by the CAP framework. It acts as a complementary to OData V4 as another option as a query language. And although it still missing some capabilities (as mentioned in the limitations section of the GraphQL adapter), it already looks promising to use productively especially if you prefer using GraphQL protocol.



Appreciate it if you have any comments, suggestions, or questions. Cheers!~

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Marcel Schwarz
      Marcel Schwarz

      Thanks for the well written blog post! In case anyone is curious, the GraphQL adapter is also open source at!