-
Notifications
You must be signed in to change notification settings - Fork 8
Description
James and I were brainstorming about decoupled approaches last night, and James asked how we could keep down requests on a page when there are things like the main content, and various sidebar blocks, etc on any given page. Ideally each of those areas is going to have it's own API endpoint which returns the relevant data/content from Drupal. So each section would typically be a new call to the API in order to pull the various content pieces together for a page.
In order to reduce the amount of calls on a given page, it would be pretty awesome to be able to concatenate or create a facade endpoint for the various endpoints you want to call for a given page. For example:
Let's say I have three endpoints:
- GET/main-content?param1=foo
- GET/sidebar1-content?param1=this¶m2=that
- GET/sidebar2-content
In the case where we have something like an AngularJS front end, we'd create a service that calls each of these endpoints individually, having three calls, and three returns.
Now if we had a facade endpoint or pipe endpoint which we could make one request and say that we need each of these at the same time, and retrieve the data for each in one payload, that would reduce the amount of calls you have to make. Something like:
- GET/pipeline?main-content=param1:foo&sidebar1-content=param1:this,param2:that&sidebar2-content
(not entirely sure that is valid format but you get the idea, right?)
Then the payload returned from this call would be your standard json object and each response would be structured accordingly to the endpoints involved.
I'm not entirely sure how this would fit into createapi itself, but I wanted to throw out the idea in case you think it could be something that would make sense to be within createapi and could provide some advice on where I might start or if you even think it makes sense at all.