API patterns to serve editorial UI and others #9945
Replies: 2 comments
-
The codebase has something like the #1 in place (regarding including extra information), but it doesn't smell very good to me. The #1 also reminds me about the JSON API pattern. I think the #1 will fit well for now. The fields returned by the API are controlled by a JSON file (see: Line 30 in 363a145 For the long term, the GraphQL discussion deserves consideration, it would address such issues in a more standard way. |
Beta Was this translation helpful? Give feedback.
-
Agreed with Jarda and I spoke a little about other options:
|
Beta Was this translation helpful? Give feedback.
-
Introduction
While working on new submission listing, there is lots data both in submission listing itself and in the submission summary.
Opening this discussion to explore what API design principles are good fit for our use cases.
We are facing typical challenges with REST api when serving the UI, these are often approached with one of the following strategy:
In the 'submission listing UI' there are two major screens. Table with list of submissions and submission summary with submission details. Lets dive more into how we deal with these challenges on these.
Submission listing
Currently we leverage private endpoint
_submissions
, which pretty much falls under strategy number (1). Everything that needs to be displayed in the table and in the review assignments popup are included in this one endpoint.This was intentionally decided to have good performance and UX. Otherwise we would have to make separate API call when Review Assignment popup is clicked on, which would delay each of these popups and make the overall listing not responsive enough.
Submission summary
When submission summary modal is opened only submissionId is passed (check Note1 for more details). And submission modal starts fetching metadata from various endpoints. And ideally if I would want to avoid over fetching, it would be following waterfall
This is one way to do it with existing API. Its fine to fetch various metadata from multiple endpoints (and there are some benefits to it as we display different metadata based on the stage and role and omp/ojs/ops). Concern in this case that it would require 3 round trips in sequence, which adds up in the latency.
Here are some patterns I can think of, maybe you can think of some additional ones:
My opinion
I think option 1) could work quite well. Query param would not support all dependencies obviously, but some particular which we find important.
I think that could help provide path to also consolidate the public (/submissions) and private (/_submissions) end points to one more flexible public one, where we could control how much dependencies to include to avoid over-fetching for example review assignments if the consumer does not need them. End result could be used by submission listing as well as other consumers (integrations, plugins).
And also option 2) is good for some cases - its already used for things like participants or files . Especially for more complex dependency, where additional query params are good for filtering the results.
There also will be considerations from the implementation point of view, where some fields and API are relevant only for some apps (ojs vs omp vs ops), so that also might affect which of these patterns is better fit. I don't have much of insights on that.
Notes
Note1: If you are wondering, why not using available submission metadata from submission listing in submission summary to reuse already fetched metadata. This assumes that the submission in summary is being currently listed in the table. And there are some edge cases when this might not be true: table will be refreshing data regularly to display current state therefore submission might slip off the listing. And more importantly there will be lots of jumping between decision page and submission summary, and when redirected back its easy to keep the submissionId as query parameter and start loading submission summary details based on that, rather than hope it will first be fetched in the table . So technically it could be considered as performance optimisation, but at this point I rather keep it simple and independent from each other.
Beta Was this translation helpful? Give feedback.
All reactions