HasManyThrough relationships always return empty data:[] array on GET
See original GitHub issueDescription
Seems when trying to GET a record that contains a HasManyThrough relationship, it returns an empty data: []
array even though I’m not specifying ?include
. Meanwhile, HasMany relationships seem to work just fine.
Here’s a somewhat-anonymized sample response (comments added) which hopefully illustrates the issue:
{
"data": [
{
"attributes": {
"title": "Sample Article",
"text": "...",
"create-date": "2018-08-14T16:19:13.653"
},
"relationships": {
"comments": { // HasMany relationship (works correctly)
"links": {
"self": "/api/articles/1/relationships/comments",
"related": "/api/articles/1/comments"
}
},
"authors": { // HasManyThrough relationship
"links": {
"self": "/api/articles/1/relationships/authors",
"related": "/api/articles/1/authors"
},
"data": [] // <-- this shouldn't be here
}
},
"type": "articles",
"id": "1"
}
]
}
To clarify, the article has authors, and they’re returned successfully when I ?include
them, so this empty array is a bit of a red herring that’s monkeying up the client application (ember-data
).
I did stumble across this issue and double-checked to make sure I’m not initializing any lists anywhere, and it doesn’t seem so. Not sure what else, if anything, might be configured differently in my project versus the repo example, so I’m a bit stumped.
Environment
- JsonApiDotNetCore Version: 3.0.0
- Other Relevant Package Versions: [?]
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
Okay no worries. It’s probably not your model then and it’s likely an issue at the serialization later of the framework. I’ll try to work on it this week.
Yup, that was it. Just made a PR. 😄