Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including recursive relationships result in null object #202

Open
goranmoomin opened this issue Aug 24, 2019 · 0 comments
Open

Including recursive relationships result in null object #202

goranmoomin opened this issue Aug 24, 2019 · 0 comments

Comments

@goranmoomin
Copy link

Including recursive relationships result in a null object.

A minimal example is here:
Backend
Frontend

As you see from the response of the API, jsonApi.findAll("a", { include: "b.a" }) should return an array with a objects that have an array with b objects which contain an a object. (Sorry for my poor English skills that can't explain it better than this.) However, the b objects' a field are always null, instead of the object.

For example, I would expect such output:

{
    "data": [
        {
            "id": "PpupN/bi1Eo8KtT/uHvm",
            "type": "as",
            "b": [],
            "links": {
                "self": "/as/PpupN%2Fbi1Eo8KtT%2FuHvm"
            }
        },
        {
            "id": "Ju6gn8yvL63rTN5Cr1zU",
            "type": "as",
            "b": [
                {
                    "id": "Z5ygOhd6cHqz1jU09maF",
                    "type": "bs",
                    "a":  {
                        "id": "Ju6gn8yvL63rTN5Cr1zU",
                        "type": "as",
                        "b": [],
                        "links": {
                            "self": "/as/Ju6gn8yvL63rTN5Cr1zU"
                        }
                    },
                    "links": {
                        "self": "/bs/Z5ygOhd6cHqz1jU09maF"
                    }
                }
            ],
            "links": {
                "self": "/as/Ju6gn8yvL63rTN5Cr1zU"
            }
        },
        {
            "id": "WFduHuyXYmkg6k6BCb+o",
            "type": "as",
            "b": [
                {
                    "id": "PoFSsKpm6ZaTkaaoj1Ln",
                    "type": "bs",
                    "a": {
                        "id": "WFduHuyXYmkg6k6BCb+o",
                        "type": "as",
                        "b": [],
                        "links": {
                            "self": "/as/WFduHuyXYmkg6k6BCb%2Bo"
                        }
                    },
                    "links": {
                        "self": "/bs/PoFSsKpm6ZaTkaaoj1Ln"
                    }
                },
                {
                    "id": "GLZwIT3E5p0dYzHD0l8z",
                    "type": "bs",
                    "a":  {
                        "id": "WFduHuyXYmkg6k6BCb+o",
                        "type": "as",
                        "b": [],
                        "links": {
                            "self": "/as/WFduHuyXYmkg6k6BCb%2Bo"
                        }
                    },
                    "links": {
                        "self": "/bs/GLZwIT3E5p0dYzHD0l8z"
                    }
                }
            ],
            "links": {
                "self": "/as/WFduHuyXYmkg6k6BCb%2Bo"
            }
        }
    ],
    "meta": {
        "count": 3
    },
    "links": {
        "self": "/as?include=b.a"
    }
}

However the current output is this:

{
    "data": [
        {
            "id": "PpupN/bi1Eo8KtT/uHvm",
            "type": "as",
            "b": [],
            "links": {
                "self": "/as/PpupN%2Fbi1Eo8KtT%2FuHvm"
            }
        },
        {
            "id": "Ju6gn8yvL63rTN5Cr1zU",
            "type": "as",
            "b": [
                {
                    "id": "Z5ygOhd6cHqz1jU09maF",
                    "type": "bs",
                    "a": null,
                    "links": {
                        "self": "/bs/Z5ygOhd6cHqz1jU09maF"
                    }
                }
            ],
            "links": {
                "self": "/as/Ju6gn8yvL63rTN5Cr1zU"
            }
        },
        {
            "id": "WFduHuyXYmkg6k6BCb+o",
            "type": "as",
            "b": [
                {
                    "id": "PoFSsKpm6ZaTkaaoj1Ln",
                    "type": "bs",
                    "a": null,
                    "links": {
                        "self": "/bs/PoFSsKpm6ZaTkaaoj1Ln"
                    }
                },
                {
                    "id": "GLZwIT3E5p0dYzHD0l8z",
                    "type": "bs",
                    "a": null,
                    "links": {
                        "self": "/bs/GLZwIT3E5p0dYzHD0l8z"
                    }
                }
            ],
            "links": {
                "self": "/as/WFduHuyXYmkg6k6BCb%2Bo"
            }
        }
    ],
    "meta": {
        "count": 3
    },
    "links": {
        "self": "/as?include=b.a"
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant