Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Stored procedures can be exposed as REST or GraphQL endpoints in DAB. This is useful for scenarios that involve custom logic, filtering, validation, or computed results not handled by simple tables or views.
Configuration
To expose a stored procedure:
- Set
source.typeto"stored-procedure" - Set
source.objectto the fully qualified procedure name - Define optional
parameterswith their defaults, if necessary - Set
rest.methods(for example,"GET","POST") orrest: false - Set
graphql.operationto"query"or"mutation", or omit to default to"mutation" - Grant permission using the
"execute"action
CLI example
dab add GetCowrittenBooksByAuthor \
--source dbo.stp_get_all_cowritten_books_by_author \
--source.type "stored-procedure" \
--source.params "searchType:default-value" \
--permissions "anonymous:execute" \
--rest.methods "get" \
--graphql.operation "query"
Configuration example
"GetCowrittenBooksByAuthor": {
"source": {
"type": "stored-procedure",
"object": "dbo.stp_get_all_cowritten_books_by_author",
"parameters": {
"searchType": "default-value"
}
},
"rest": {
"methods": [ "GET" ]
},
"graphql": {
"operation": "query"
},
"permissions": [
{
"role": "anonymous",
"actions": [ "execute" ]
}
]
}
REST support
- Supports only
GETandPOST - Defaults to
POSTifmethodsis omitted - Sends parameters via query string with
GET - Sends parameters via JSON body with
POST - Disables REST for a stored procedure if
"rest": falseis set
Example requests
GET /api/GetCowrittenBooksByAuthor?author=asimov
POST /api/GetCowrittenBooksByAuthor
{
"author": "asimov"
}
GraphQL support
- Requires
graphql.operationto be"query"or"mutation" - Fields are autoprefixed with
execute, for example,executeGetCowrittenBooksByAuthor - Parameters are passed as GraphQL arguments
Example GraphQL
query {
executeGetCowrittenBooksByAuthor(author: "asimov") {
id
title
}
}
Limitations
- Only the first result set is returned
- Pagination, filtering, and ordering aren't supported
- Relationships aren't supported
- Requires metadata from
sys.dm_exec_describe_first_result_set - Can't return a single item by key
- No parameter-level authorization