telescope icon indicating copy to clipboard operation
telescope copied to clipboard

[Post-services] Add `author`, `title`, `publishDate` fields to '/' route

Open Kevan-Y opened this issue 2 years ago • 2 comments

Our current Post-services / route will return an array of posts see JSON below.

[
  {
    "id": "33a8c63f31",
    "url": "https://api.telescope.cdot.systems/v1/posts/33a8c63f31"
  },
  {
    "id": "6f3d109b82",
    "url": "https://api.telescope.cdot.systems/v1/posts/6f3d109b82"
  },
  {
    "id": "3253659d90",
    "url": "https://api.telescope.cdot.systems/v1/posts/3253659d90"
  }
  ]

Since our React native app design uses a click and reads design. When fetching the list of posts, we have to do another fetch to get author, title, date. This is inefficient since it makes a lot of unnecessary requests, we only need to request post detail on click to a post. image

The solution is to add author, title, and publishDate to the object. Sample JSON:

[
  {
    "id": "33a8c63f31",
    "url": "https://api.telescope.cdot.systems/v1/posts/33a8c63f31",
    "author":"",
    "title":"",
    "publishDate":""
  },
  {
    "id": "6f3d109b82",
    "url": "https://api.telescope.cdot.systems/v1/posts/6f3d109b82",
     "author":"",
    "title":"",
    "publishDate":""
  },
  {
    "id": "3253659d90",
    "url": "https://api.telescope.cdot.systems/v1/posts/3253659d90",
     "author":"",
    "title":"",
    "publishDate":""
  }
  ]

Kevan-Y avatar May 21 '22 02:05 Kevan-Y

Probably adding some kind of URL param to return a fully hydrated object is best (i.e., don't do it unless requested). For example:

  • GET /posts returns id and url only (current behaviour)
  • GET /posts?expand=1 returns some version of what you suggest above

This way you can opt into the extra calls this will require.

humphd avatar May 24 '22 13:05 humphd

Probably adding some kind of URL param to return a fully hydrated object is best (i.e., don't do it unless requested). For example:

* `GET /posts` returns `id` and `url` only (current behaviour)

* `GET /posts?expand=1` returns some version of what you suggest above

This way you can opt into the extra calls this will require.

I agree.

DukeManh avatar May 29 '22 00:05 DukeManh

Hi,

Can I have this? I've already fixed this issue.

Does this fixed version look right? image

liutng avatar Nov 16 '22 21:11 liutng

Hi,

Can I have this? I've already fixed this issue.

Does this fixed version look right?

image

Welcome, great it seems what we want.

This use case is mainly for the mobile app.

Kevan-Y avatar Nov 18 '22 21:11 Kevan-Y

Closed via #3771

manekenpix avatar Nov 29 '22 20:11 manekenpix