Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

Comment schema needs embed context #1287

Closed
rachelbaker opened this issue May 25, 2015 · 9 comments · Fixed by #1284
Closed

Comment schema needs embed context #1287

rachelbaker opened this issue May 25, 2015 · 9 comments · Fixed by #1284
Assignees
Labels
Milestone

Comments

@rachelbaker
Copy link
Member

The comment schema doesn't include any response fields in the embed context right now, which means when embedding the related data for a single post the response data is empty.

Example:

"_embedded": {
    ...
    "replies": [
        [ 
        { 
            "_links": {
                "self": [
                    {
                    "href": "http://vagrant.local/wp-json/wp/v2/comments/3"
                    }
                ],
                "collection": [
                    {
                    "href": "http://vagrant.local/wp-json/wp/v2/comments"
                    }
                ],
                "author": [
                    {
                    "embeddable": true,
                    "href": "http://vagrant.local/wp-json/wp/v2/users/1"
                    }
                ],
                "post": [
                    {
                    "embeddable": true,
                    "href": "http://vagrant.local/wp-json/wp/v2/posts/5"
                    }
                ]
            }
        }
    ] ],
    ...
}
@rachelbaker rachelbaker added this to the 2.0 Beta 2 milestone May 25, 2015
@rachelbaker rachelbaker self-assigned this May 25, 2015
@rachelbaker
Copy link
Member Author

@WP-API/amigos Proposed response fields for the comments embed context:

  • id
  • author_name
  • author_url
  • date
  • content[rendered]

Thoughts?

The embedded response would then look like this:

"_embedded": {
    ...
    "replies": [
        [
            {
                "id": 3,
                "author_name": "admin",
                "author_url": "",
                "date": "2015-05-25T15:06:45",
                "content": {
                    "rendered": "<p>Worst episode ever.</p>\n"
                },
                "link": "http://vagrant.local/2015/05/20/marge-vs-monorail/#comment-3",
                "_links": {
                    "self": [
                        {
                            "href": "http://vagrant.local/wp-json/wp/v2/comments/3"
                        }
                    ],
                    "collection": [
                        {
                            "href": "http://vagrant.local/wp-json/wp/v2/comments"
                        }
                    ],
                ...
                }
    },
    ...
}

@danielbachhuber
Copy link
Member

Proposed response fields for the comments embed context:

Probably need avatar_url and parent in there too.

@rachelbaker
Copy link
Member Author

@danielbachhuber Good call!

@rachelbaker
Copy link
Member Author

@danielbachhuber Actually avatar_url is not a field in the Comment item response. I created #1290 to discuss and track adding that field.

@rmccue
Copy link
Member

rmccue commented May 25, 2015

I added a basic set in dc8c14e on #1284:

  • id
  • author
  • author_name
  • author_url
  • content
  • date
  • date_gmt
  • status
  • type

Probably don't need both date and date_gmt, and probably should add parent. Essentially, we should have everything we need to display comments on a post page.

@rachelbaker
Copy link
Member Author

@rmccue I didn't see your comment before pushing #1291. There I only include:

id
parent
author_name
author_url
content[rendered]
date
link
post

How should we resolve?

@rmccue
Copy link
Member

rmccue commented May 26, 2015

@rachelbaker I'll add parent and link to my set, and remove date_gmt. I don't think we need post though, since the main use case for embedding comments is in the post itself, so that's not really useful.

@rmccue
Copy link
Member

rmccue commented May 26, 2015

Turns out I misread and didn't actually have date_gmt and I had link and parent anyway :)

I don't think you really need status since it should always be approved, so I'll remove that one. type would be useful if the query was comments + pingbacks + trackbacks (to match core's handling), but right now it's just comments. Maybe that should change?

@rachelbaker
Copy link
Member Author

Closing in favor of #1284

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants