Summary
Allow a single DAB instance to interact with multiple backend data sources.
Motivation
This design enables DAB to address more sophisticated customers.
Old behavior
Currently, DAB supports only a single data source and a single dab-config.json file.
Barriers to multiple data sources:
- The
data-source property in the config is of type object, not array.
- The
data-source property in the config applies to every entity.
New behavior
Support the use of multiple dab-config.json files, each corresponding to a different data-source, to merge at runtime.
⭐ When DAB starts, the GLOBAL and CHILD files will be merged.
Design goals:
- A single
dab-config.json file must always be viable in DAB.
- We will not impose arbitrary limits on
data-source or entities at this time.
- Developers must easily understand which file has an error.
entity names across all files must be unique to support future features.
Sample global file
{
"$schema": "https://github.com/Azure/data-api-builder/releases/download/v0.7.6/dab.draft.schema.json",
"data-source-files": [
"dab-config.mssql-hr.json",
"dab-config.cosmosdb-sales.json",
"dab-config.mysql-inventory.json",
"dab-config.postgres-shipping.json",
],
...
}
Global file characteristics
- The global file must have
runtime properties.
- The global file's
data-source property is optional.
- The global file's
data-source-files property is optional.
- Paths in
data-source-files may include Unicode characters.
New data-source-files property in JSON schema.
{
"$schema": "https://json-schema.org/draft-07/schema",
"data-source-files": { // new property
"type": "array",
"description": "Child file paths",
"items": {
"type": "string"
},
"default": []
}
}
This new property, of type string[], is optional. If the data-source-files property is [] or omitted, the data-source property is required. Otherwise, the data-source property is optional.
Path translation
When filled, the data-source-files property contains paths to child files. These paths can include dots . and slashes / & \, indicating the location of the child file relative to the global config file.
If the global config file is at c:\web\api\dab-config.json, then:
| Path in Config |
File Location |
dab-config.02.json |
c:\web\api\dab-config.02.json |
./dab-config.03.json |
c:\web\api\dab-config.03.json |
../dab-config.04.json |
c:\web\dab-config.04.json |
/other/dab-config.05.json |
c:\web\api\other\dab-config.05.json |
../web/dab-config.06.json |
c:\web\api\dab-config.06.json |
Child file characteristics
- A child file must have a
data source defined.
- A child file may define
data-source-files, which can be thought of as "grandchild" files.
- A child file may be used as a global file if it has
runtime properties set.
- If a child file has
runtime properties, they will be ignored; the global file is always used.
- A child file can be named anything and be located in any accessible folder relative to the global file.
Summary
Allow a single DAB instance to interact with multiple backend data sources.
Motivation
This design enables DAB to address more sophisticated customers.
Old behavior
Currently, DAB supports only a single
data sourceand a singledab-config.jsonfile.Barriers to multiple data sources:
data-sourceproperty in the config is of typeobject, notarray.data-sourceproperty in the config applies to everyentity.New behavior
Support the use of multiple
dab-config.jsonfiles, each corresponding to a differentdata-source, to merge at runtime.⭐ When DAB starts, the GLOBAL and CHILD files will be merged.
Design goals:
dab-config.jsonfile must always be viable in DAB.data-sourceorentitiesat this time.entitynames across all files must be unique to support future features.Sample global file
{ "$schema": "https://github.com/Azure/data-api-builder/releases/download/v0.7.6/dab.draft.schema.json", "data-source-files": [ "dab-config.mssql-hr.json", "dab-config.cosmosdb-sales.json", "dab-config.mysql-inventory.json", "dab-config.postgres-shipping.json", ], ... }Global file characteristics
runtimeproperties.data-sourceproperty is optional.data-source-filesproperty is optional.data-source-filesmay include Unicode characters.New
data-source-filesproperty in JSON schema.{ "$schema": "https://json-schema.org/draft-07/schema", "data-source-files": { // new property "type": "array", "description": "Child file paths", "items": { "type": "string" }, "default": [] } }This new property, of type
string[], is optional. If thedata-source-filesproperty is[]or omitted, thedata-sourceproperty is required. Otherwise, thedata-sourceproperty is optional.Path translation
When filled, the
data-source-filesproperty contains paths to child files. These paths can include dots.and slashes/&\, indicating the location of the child file relative to the global config file.If the global config file is at
c:\web\api\dab-config.json, then:dab-config.02.jsonc:\web\api\dab-config.02.json./dab-config.03.jsonc:\web\api\dab-config.03.json../dab-config.04.jsonc:\web\dab-config.04.json/other/dab-config.05.jsonc:\web\api\other\dab-config.05.json../web/dab-config.06.jsonc:\web\api\dab-config.06.jsonChild file characteristics
data sourcedefined.data-source-files, which can be thought of as "grandchild" files.runtimeproperties set.runtimeproperties, they will be ignored; the global file is always used.