Configuração do construtor de API de Dados de Exemplo
Esta configuração de exemplo ilustrava um cenário ponto a ponto. Este cenário utiliza SQL do Azure Base de Dados como base de dados de apoio e Aplicações Web Estáticas do Azure como anfitrião.
Este exemplo é derivado das tabelas e dados fornecidos no script SQL de exemplo da Biblioteca.
{
"$schema": "https://github.com/Azure/data-api-builder/releases/download/v0.10.23/dab.draft.schema.json",
"data-source": {
"database-type": "mssql",
"connection-string": "@env('my-connection-string')",
"options": {
"set-session-context": false
}
},
"runtime": {
"rest": {
"enabled": true,
"path": "/api",
"request-body-strict": false
},
"graphql": {
"enabled": true,
"path": "/graphql",
"allow-introspection": true
},
"host": {
"cors": {
"origins": [],
"allow-credentials": false
},
"authentication": {
"provider": "StaticWebApps"
},
"mode": "development"
}
},
"entities": {
"authors": {
"source": {
"object": "[dbo].[authors]",
"type": "table",
"key-fields": [ "id" ]
},
"graphql": {
"enabled": true,
"type": {
"singular": "authors",
"plural": "authors"
}
},
"rest": {
"enabled": true
},
"permissions": [
{
"role": "anonymous",
"actions": [
{
"action": "*",
"fields": {
"exclude": [ "middle_name" ],
"include": [
"id",
"first_name",
"last_name"
]
}
}
]
}
],
"mappings": { "id": "key" },
"relationships": {
"books": {
"cardinality": "many",
"target.entity": "books",
"source.fields": [],
"target.fields": [],
"linking.object": "dbo.books_authors",
"linking.source.fields": [ "author_id" ],
"linking.target.fields": [ "book_id" ]
}
}
},
"series": {
"source": {
"object": "[dbo].[series]",
"type": "table",
"key-fields": [ "id" ]
},
"graphql": {
"enabled": true,
"type": {
"singular": "series",
"plural": "series"
}
},
"rest": {
"enabled": true
},
"permissions": [
{
"role": "anonymous",
"actions": [
{
"action": "*"
}
]
}
],
"relationships": {
"books": {
"cardinality": "many",
"target.entity": "books",
"source.fields": [ "id" ],
"target.fields": [ "series_id" ],
"linking.source.fields": [],
"linking.target.fields": []
}
}
},
"books": {
"source": {
"object": "[dbo].[books]",
"type": "table",
"key-fields": [ "id" ]
},
"graphql": {
"enabled": true,
"type": {
"singular": "books",
"plural": "books"
}
},
"rest": {
"enabled": true
},
"permissions": [
{
"role": "anonymous",
"actions": [
{
"action": "*"
}
]
}
],
"relationships": {
"series": {
"cardinality": "one",
"target.entity": "series",
"source.fields": [ "series_id" ],
"target.fields": [ "id" ],
"linking.source.fields": [],
"linking.target.fields": []
},
"authors": {
"cardinality": "many",
"target.entity": "authors",
"source.fields": [],
"target.fields": [],
"linking.object": "dbo.books_authors",
"linking.source.fields": [ "book_id" ],
"linking.target.fields": [ "author_id" ]
}
}
},
"books_authors": {
"source": {
"object": "[dbo].[books_authors]",
"type": "table",
"key-fields": [
"book_id",
"author_id"
]
},
"graphql": {
"enabled": false,
"type": {
"singular": "books_authors",
"plural": "books_authors"
}
},
"rest": {
"enabled": true
},
"permissions": [
{
"role": "anonymous",
"actions": [
{
"action": "*"
}
]
}
]
}
}
}