Today customer or developer has to feed-in schema information in the form of schema.gql file while setting up DAB.
What is this change?
As part of this feature, Customer would have option to let DAB generates the schema on startup.
So it means:
Customer can pass schema.gql file, as they pass today
If schema.gql file is not passed, DAB will generate the same schema and load it in during startup itself.
a) By default, it will take the top 1 record from the container.
b) It would be configurable in config file, where developer can mention the sample size (min: 10, max: 20).
c) Developer can write a custom Cosmos DB query which will be used to generate the schema.
What if both configs are there?
user passed schema i.e. schema.gql file, will get more preference than generating schema.
High Level Design
flowchart TD
Engine[fa:fa-cogs DAB Engine]-->| when initialized | CheckConfig{fa:fa-user Is user provided graphql.gql schema?}
CheckConfig -->|yes| LoadConfig
CheckConfig -->|no| GenerateConfig:::bar
subgraph GenerateConfig[Schema Generation]
b[fa:fa-sitemap Read Schema Analyzer Config from db-config.json] --> userconfigured{fa:fa-user is user configured?}
userconfigured -->|yes| LoadFromConfigFile[fa:fa-file-alt Load config from db-config.json]
userconfigured -->|No| LoadDefaultConfig[fa:fa-file-alt Load default config i.e. select top 10 data]
LoadDefaultConfig --> c
LoadFromConfigFile --> c[fa:fa-file-excel Query Cosmos DB get Sample data]
c --> d[fa:fa-tools Schema Generator]
g[fa:fa-database Database configured in db-config.json] --> c
end
subgraph LoadConfig[fa:fa-upload Load GraphQL.gql]
f[fa:fa-file Read schema file]
end
d -->|Returns GQL schema in string format| GenerateSchema
LoadConfig -->|Returns GQL schema in string format| GenerateSchema[fa:fa-spinner Generate and Cache Graphql schema]
GenerateSchema --> MemoryData[fa:fa-file In-Memory Store]
classDef bar stroke:#0f0
How was this tested?
[ ] Integration Tests
[ ] Unit Tests
Sample Request(s)
Example REST and/or GraphQL request to demonstrate modifications
Why make this change?
Today customer or developer has to feed-in schema information in the form of
schema.gql
file while setting up DAB.What is this change?
As part of this feature, Customer would have option to let DAB generates the schema on startup.
So it means:
Customer can pass![image](https://github.com/Azure/data-api-builder/assets/6362382/50fdd33e-123d-4214-ad72-e892069adc67)
schema.gql
file, as they pass todayIf![image](https://github.com/Azure/data-api-builder/assets/6362382/238fc8a5-bfce-45b9-bae5-08742431165a)
schema.gql
file is not passed, DAB will generate the same schema and load it in during startup itself. a) By default, it will take thetop 1
record from the container. b) It would be configurable in config file, where developer can mention the sample size (min: 10, max: 20). c) Developer can write a custom Cosmos DB query which will be used to generate the schema.What if both configs are there?
user passed schema i.e.
schema.gql
file, will get more preference than generating schema.High Level Design
How was this tested?
Sample Request(s)