Configuring REST and GraphQL Endpoints
This lesson explains runtime and entity settings for REST and GraphQL and the operations each endpoint offers.
Learning outcomes
After completing this lesson, you will be able to:
- Describe the runtime settings for REST and GraphQL.
- Identify the REST methods and GraphQL operations DAB generates.
- Explain how to enable or hide endpoints per entity.
Runtime endpoint settings
runtime.rest enables or disables REST for all entities, sets its base path (default /api) and sets request-body-strict, which rejects unknown fields in request bodies when true. runtime.graphql enables or disables GraphQL, sets its path (default /graphql), and controls allow-introspection, a depth-limit for nested queries and multiple-mutations.create.enabled, which allows inserting related rows in one mutation. Disabling an endpoint globally overrides entity settings.
Endpoint settings
REST operations
For a table or view entity, REST exposes the HTTP methods shown in the following table, where the primary key appears in the URL path.
| Request | Operation |
|---|---|
| GET /api/Product | List rows (paged) |
| GET /api/Product/ProductID/42 | Read one row by key |
| POST /api/Product | Insert a row from the JSON body |
| PUT /api/Product/ProductID/42 | Replace a row, or insert it if it does not exist (upsert) |
| PATCH /api/Product/ProductID/42 | Update the fields in the body, or insert (incremental upsert) |
| DELETE /api/Product/ProductID/42 | Delete a row |
Stored procedure entities are called with the methods in their rest.methods setting (POST by default), with parameters in the body or query string. An entity's rest.path renames its route, and rest.enabled: false hides it from REST while keeping GraphQL.
REST requests
GraphQL operations
GraphQL exposes one endpoint with a schema generated from the entities. Each entity gets a query for a single item by key and a query for a paged list, named from graphql.type (singular and plural), plus createX, updateX and deleteX mutations. A stored procedure appears as executeX under Query or Mutation according to graphql.operation. Clients ask for exactly the fields they need, including related entities, in one request.
query {
products(filter: { ListPrice: { lt: 200 } }, orderBy: { Name: ASC }, first: 10) {
items { ProductID Name ListPrice }
hasNextPage
endCursor
}
}GraphQL in DAB
GraphQL only for one entity
A mobile app uses GraphQL for every entity. The OrderAudit entity must be readable through GraphQL by administrators but must not have a REST route at all, while other entities keep both. What should the developer configure?
Set rest.enabled to false on the OrderAudit entity (for example with dab update OrderAudit --rest false) and keep its GraphQL enabled with read permission for the administrator role. Disabling runtime.rest would remove REST from every entity, and removing permissions would hide the entity from GraphQL too.
What does request-body-strict set to true do?
Show answer
It rejects REST request bodies that contain fields not in the entity.
Exam Tips
Remember for the exam
- Global switches and paths: runtime.rest and runtime.graphql.
- Per-entity control: rest.enabled, rest.path, graphql.enabled and graphql.type.
- Production GraphQL: consider disabling introspection and setting a depth limit.
- Stored procedures: REST methods (POST by default) and execute fields in GraphQL.