Understanding the Data Service API

The Data Service provides a RESTful API to manage the data associated with each scenario. For more details, please refer to Chapter Understanding the Data Service.

The API endpoints are described in the Data Service OpenAPI documentation. For convenience, the Data Service OpenAPI specification file can be converted to most languages using OpenAPI Generator.

The Data Service API can be invoked from Java through the client class DataServiceClient interface. This interface is provided by the library com.decisionbrain.gene:data-service-client. It must be configured by including the annotation @EnableDataServiceClient in the configuration of your microservice. For more details, please refer to the DataServiceClient JavaDoc.

To be able to use this API, import the library data-service-client:

dependencies {
    implementation 'com.decisionbrain.gene:data-service-client:${versions.decisionbrain.dbgene}'
}

Be sure to configure the Data Service URL and port in the application.yml of your service. Here is an example of the configuration:

services:
    data:
        host: localhost
        port: 8081

To communicate with the web client, the Data Service uses the GraphQL framework.

By default, Queries (to read data) and Mutations (to alter data) are generated at application startup and defined in the application GraphQL schema.

Note:

Note that, in a development environment, you can explore exposed types, queries, and mutations using the graphiql interface. It is available from the data server URL path /graphiql, by default http://localhost:8082/graphiql.

To have a better idea, some of the default queries that are generated for a given entity (called Entity1, for example) are described in Section Understanding GraphQL Default Queries.

There are different ways to use GraphQL queries on scenario data. For more details, please refer to Sections Understanding GraphQL Default Mutations and Understanding GraphQL Custom Queries.

Data from different scenarios of the same type can be compared. For more details, please refer to Section Understanding GraphQL Scenario Comparison.

Finally, the GraphQL "introspection" feature can be enabled during development and disabled in deployments. For more details, please refer to Section Understanding GraphQL Introspection.