Skip to content
Search

    Protocol Adapters

    Protocol Adapters translate inbound requests and messages into instances of cds.Request and cds.Query.

    GraphQL Adapter (experimental)

    The GraphQL adapter can be activated by setting config option:

    • cds.env.features.graphql = true

    Further, you need to install the following additional dependencies:

    • @graphql-tools/schema
    • express-graphql
    • graphql

    The adapter serves a single endpoint for all services based on the served event at /graphql. At that path, you’ll find a generated UI (via third party library) that allows you to interact with your application.

    Follow these steps to run @capire/bookshop with graphql:

    1. npm add graphql express-graphql @graphql-tools/schema
    2. cds_features_graphql=true cds w bookshop
    3. Open GraphiQL client at http://localhost:4004/graphql.
    4. Browse schema and enter queries in the GraphiQL client.

    GraphiQL

    For example, you can execute queries like the following:

    {
      CatalogService {
        Books {
          ID
          title
          genre {
            name
          }
        }
      }
    }
    

    The equivalent query in OData:

    GET /browse/Books?$select=ID,title&$expand=genre($select=name)
    

    Various limitations apply. For example, authentication and authorization are out of scope, and annotations aren’t considered during schema generation.

    Note that the GraphQL adapter isn’t supported for productive usage!

    GraphQL Schema Using CLI (experimental)

    The GraphQL schema can be generated stand-alone via cds compile -2 gql.

    More to Come

    This documentation is not complete yet, or some APIs are not released for general availability. There’s more to come in this place in upcoming releases.