Management API: Add bulk fetch endpoints for Document Types, Media Types, Member Types, and Data Types #21565
+1,065
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
On the first load - after sign-in, following a direct link, or a refresh - of a document there are often several requests for document and data types. This particular the case where block editors are used.
As a potential performance improvement, we could look to load all the necessary types in a one request per type, rather than one request per item.
This PR adds additional endpoints to the management API to retrieve full entity details for document, media, member and data types that are identified by a provided collection of IDs.
Change Details
GET /umbraco/management/api/v1/{entity-type}/fetch?id=guid1&id=guid2endpoints to retrieve multiple full entity definitions by ID in a single requestFetchResponseModel<T>withTotalcount andItemscollectionOrderByRequestedIds<TEntity>()helper method toManagementApiControllerBasefor consistent ordering, ensuring that found items are returned in the same order as requested.New Endpoints
GET /document-type/fetch?id=guid1&id=guid2FetchResponseModel<DocumentTypeResponseModel>GET /media-type/fetch?id=guid1&id=guid2FetchResponseModel<MediaTypeResponseModel>GET /member-type/fetch?id=guid1&id=guid2FetchResponseModel<MemberTypeResponseModel>GET /data-type/fetch?id=guid1&id=guid2FetchResponseModel<DataTypeResponseModel>Design Decisions
Why GET instead of POST?
We considered both approaches:
POST (request body)
GET (query parameters)
GET /item/document-type?id=x&id=y); cacheableAfter some discussion, we chose GET because:
?id=query parameter patternWhy the
/fetchsuffix?The
/fetchsuffix is used to:GET /document-type(without suffix) could be used for a future paged list endpoint (e.g.,GET /document-type?skip=0&take=100)GET /document-type/{id}Request/Response Format
Request:
Response:
{ "total": 2, "items": [ { /* full entity response model */ }, { /* full entity response model */ } ] }Behavior
totalto requested count to determine if this is the case if necesssary)Testing
I've run through the following using the Swagger UI interface.
GET /document-type/fetch?id=...returns correct document typesGET /media-type/fetch?id=...returns correct media typesGET /member-type/fetch?id=...returns correct member typesGET /data-type/fetch?id=...returns correct data typesFollowing existing patterns for management API endpoints, integration tests have been added only to verify authorization is enforced per entity type.