-
-
Notifications
You must be signed in to change notification settings - Fork 158
HasManyThrough relationships always return empty data:[] array on GET #453
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
Comments
Yeah the only time I've seen this issue is when the list is initialized somewhere. Can you post your model? One thing you might try is adding a log entry (or setting a breakpoint) to the setter: (roughly) public class Article : Identifiable {
private List<Tag> _tags;
[HasManyThrough("tag", nameof(ArticleTags))]
public List<Tag> Tags {
get => _tags
set {
Console.WriteLine("ArticleTags set with size " + value?.Length);
Console.WriteLine(Environment.StackTrace);
_tags = value;
}
}
} |
Thanks for the response! I gave the logging a shot, and it doesn't seem that It'll take me just a bit to post up the models. The example is anonymized so I gotta shuffle the names around and make sure I didn't break anything. :P [EDIT] Welp, uh... substitute "Author" for "Tags", I guess. Forgot my example was a bit different than the built-in one. |
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. |
Bit of a stab in the dark, but do you think this function could be the culprit? It seems like it's going to ship back an empty |
…for HasManyThrough)
…ips when building resource graph
Yup, that was it. Just made a PR. :D |
Description
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:
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
The text was updated successfully, but these errors were encountered: