-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API endpoint concatenation #5
Comments
I think this is mixing the concepts of data and presentation by thinking of it as a "sidebar feed", in fact you can already achieve this. A good example is the LLX Site, which has "Touts". These are just content types with a title and a blob of text (so like a block). Different positions in the front-end app can be filled by touts/blocks, which are configured in the back end: The initial site settings payload then gives you the IDs for these: Which you can then get more information out of from the touts feed: |
I'm not really talking about the sidebar, that was just an example to illustrate that there are different areas on the site that would require multiple calls to the API. The idea is that if you have a lot of API calls on one page, it would be able to still get all of the data needed for a page through one call instead of multiple calls. And if that is possible, I thought it might be a god generalized function within this module to provide to it's users. The examples you're giving here seem like you're still making two calls vs one anyway (if i'm reading this correctly). |
Ahh I see. Do you know roughly how many individual feeds would need concatenating for this to become a benefit? Like, what's the overhead for making a request and how many concurrent requests can you do at one time? Since instead of being able to process highly cacheable individual feeds and render them as they arrive, now the page is entirely held up by one large data dump coming from a source that potentially needs building when requested. |
|
I was searching around for combining multiple AJAX requests into one, and came across this.
|
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:
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:
(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.
The text was updated successfully, but these errors were encountered: