Configurazione del generatore di API dati di esempio
Questa configurazione di esempio illustra uno scenario end-to-end. Questo scenario usa Azure SQL Database come database di backup e App Web statiche di Azure come host.
Questo esempio è derivato dalle tabelle e dai dati forniti nello script SQL di esempio della libreria.
{
"$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": "*"
}
]
}
]
}
}
}