Skip to content

Included compound documents are being included recursively #126

@jsenecal

Description

@jsenecal

On a model having a relation with itself, including the relation will have the consequence of including the fields in the relation itself.

http://localhost:8000/api/contacts/organizations/534?format=vnd.api%2Bjson&include=resellers,people&fields[organization]=resellers,people&fields[person]=full_name

{
    "data": {
        "type": "organization",
        "id": "534",
        "attributes": {},
        "relationships": {
            "resellers": {
                "data": [
                    {
                        "type": "organization",
                        "id": "4"
                    }
                ],
                "links": {
                    "self": "http://api-dev.zerofail.com:8080/api/contacts/organizations/534/relationships/resellers?format=vnd.api%2Bjson",
                    "related": "http://api-dev.zerofail.com:8080/api/contacts/organizations/534/resellers?format=vnd.api%2Bjson"
                },
                "meta": {
                    "count": 1
                }
            },
            "people": {
                "data": [
                    {
                        "type": "person",
                        "id": "628"
                    },
                    {
                        "type": "person",
                        "id": "1022"
                    }
                ],
                "links": {
                    "self": "http://api-dev.zerofail.com:8080/api/contacts/organizations/534/relationships/people?format=vnd.api%2Bjson",
                    "related": "http://api-dev.zerofail.com:8080/api/contacts/organizations/534/people?format=vnd.api%2Bjson"
                },
                "meta": {
                    "count": 2
                }
            }
        },
        "links": {
            "self": "http://api-dev.zerofail.com:8080/api/contacts/organizations/534?format=vnd.api%2Bjson"
        }
    },
    "included": [
        {
            "type": "organization",
            "id": "4",
            "attributes": {},
            "relationships": {
                "resellers": {
                    "data": [
                        {
                            "type": "organization",
                            "id": "504"
                        }
                    ],
                    "links": {
                        "self": "http://api-dev.zerofail.com:8080/api/contacts/organizations/4/relationships/resellers?format=vnd.api%2Bjson",
                        "related": "http://api-dev.zerofail.com:8080/api/contacts/organizations/4/resellers?format=vnd.api%2Bjson"
                    },
                    "meta": {
                        "count": 1
                    }
                },
                "people": {
                    "data": [
                        {
                            "type": "person",
                            "id": "111"
                        },
                        {
                            "type": "person",
                            "id": "1783"
                        },
                        {
                            "type": "person",
                            "id": "1985"
                        },
                        {
                            "type": "person",
                            "id": "648"
                        },
                        {
                            "type": "person",
                            "id": "421"
                        },
                        {
                            "type": "person",
                            "id": "353"
                        }
                    ],
                    "links": {
                        "self": "http://api-dev.zerofail.com:8080/api/contacts/organizations/4/relationships/people?format=vnd.api%2Bjson",
                        "related": "http://api-dev.zerofail.com:8080/api/contacts/organizations/4/people?format=vnd.api%2Bjson"
                    },
                    "meta": {
                        "count": 6
                    }
                }
            },
            "links": {
                "self": "http://api-dev.zerofail.com:8080/api/contacts/organizations/4?format=vnd.api%2Bjson"
            }
        },
        {
            "type": "person",
            "id": "1022",
            "attributes": {
                "full_name": "Neppie Abernathy"
            },
            "links": {
                "self": "http://api-dev.zerofail.com:8080/api/contacts/people/1022?format=vnd.api%2Bjson"
            }
        },
        {
            "type": "person",
            "id": "111",
            "attributes": {
                "full_name": "Mrs. Ernestine Bartoletti"
            },
            "links": {
                "self": "http://api-dev.zerofail.com:8080/api/contacts/people/111?format=vnd.api%2Bjson"
            }
        },
        {
            "type": "person",
            "id": "1783",
            "attributes": {
                "full_name": "Adrain Franecki"
            },
            "links": {
                "self": "http://api-dev.zerofail.com:8080/api/contacts/people/1783?format=vnd.api%2Bjson"
            }
        },
        {
            "type": "person",
            "id": "1985",
            "attributes": {
                "full_name": "Mr. Dandre Haley"
            },
            "links": {
                "self": "http://api-dev.zerofail.com:8080/api/contacts/people/1985?format=vnd.api%2Bjson"
            }
        },
        {
            "type": "person",
            "id": "353",
            "attributes": {
                "full_name": "Mrs. Harlene VonRueden"
            },
            "links": {
                "self": "http://api-dev.zerofail.com:8080/api/contacts/people/353?format=vnd.api%2Bjson"
            }
        },
        {
            "type": "person",
            "id": "421",
            "attributes": {
                "full_name": "Miss Jasmin Kutch"
            },
            "links": {
                "self": "http://api-dev.zerofail.com:8080/api/contacts/people/421?format=vnd.api%2Bjson"
            }
        },
        {
            "type": "person",
            "id": "628",
            "attributes": {
                "full_name": "Dr. Beckham Abernathy"
            },
            "links": {
                "self": "http://api-dev.zerofail.com:8080/api/contacts/people/628?format=vnd.api%2Bjson"
            }
        },
        {
            "type": "person",
            "id": "648",
            "attributes": {
                "full_name": "Creed Kuhn"
            },
            "links": {
                "self": "http://api-dev.zerofail.com:8080/api/contacts/people/648?format=vnd.api%2Bjson"
            }
        }
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions