Skip to content

Add the "relationships" prop in base included resources #239

@spersico

Description

@spersico

While testing localhost:3000/articles/1?include=author.votes

The included author in that same response, should also have the votes relationshipObjects in its "relationships" property:

{
    "data": {
        "id": 1,
        "type": "article",
        "attributes": {
            "body": "this is test 1",
            "voteCount": 2
        },
        "relationships": {
            "author": {
                "data": {
                    "id": 1,
                    "type": "user"
                }
            },
            "votes": {
                "data": [
                    {
                        "id": 1,
                        "type": "vote"
                    },
                    {
                        "id": 2,
                        "type": "vote"
                    }
                ]
            }
        }
    },
    "included": [
        {
            "id": 1,
            "type": "user",
            "attributes": {
                "username": "me",
                "email": "me@me.com",
                "createdAt": null,
                "updatedAt": null
            },
            "relationships": {
 // HERE THE VOTES RELATIONSHIP OBJECTS SHOULD ALSO APPEAR!
// JUST LIKE IN THE ARTICLE (id & type)
}
        },
        {
            "id": 1,
            "type": "vote",
            "attributes": { ... },
            "relationships": {
                "user": {
                    "data": {
                        "id": 1,
                        "type": "user"
                    }
                },
                "article": {
                    "data": {
                        "id": 1,
                        "type": "article"
                    }
                }
            }
        },
        {
            "id": 2,
            "type": "vote",
            "attributes": {... },
            "relationships": {
                "user": {
                    "data": {
                        "id": 1,
                        "type": "user"
                    }
                },
                "article": {
                    "data": {
                        "id": 1,
                        "type": "article"
                    }
                }
            }
        }
    ]
}

Originally posted by @spersico in #227 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    ⌛ Waiting

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions