Description
Description
Hi folks. I'm seeing some odd behavior setting up / fetching relationships. I have two entities, subscription
and pricingTier
. pricingTier
hasMany subscription
and subscription
hasOne pricingTier
, which seems straightforward enough.
When requesting /api/pricing-tier
, I see:
"relationships": {
"plan": {
"links": {
"self": "https://localhost:5000/api/pricing-tier/1/relationships/plan",
"related": "https://localhost:5000/api/pricing-tier/1/plan"
},
"data": {
"type": "plan",
"id": "1"
}
},
"subscription": {
"links": {
"self": "https://localhost:5000/api/pricing-tier/1/relationships/subscription",
"related": "https://localhost:5000/api/pricing-tier/1/subscription"
},
"data": []
}
},
...note the empty array under data
for the HasMany, but not the HasOne relationship to plan
Requesting /api/pricing-tier?inclue=subscription
instead gets me:
"subscription": {
"links": {
"self": "https://localhost:5000/api/pricing-tier/1/relationships/subscription",
"related": "https://localhost:5000/api/pricing-tier/1/subscription"
},
"data": [
{
"type": "subscription",
"id": "1"
}
]
}
...plus the "included" collection that I'd expect.
I'm a little confused as to whether this is an error somewhere in my model setup or this is by design. I think I followed the examples reasonably closely, and to make sure it wasn't a problem with my DB-first approach, I've been using migrations on a fresh DB, but the problem has persisted.
Any help greatly appreciated! If it's not by design and it's a problem with my setup, I can provide the relevant file excerpts.
Thanks!
Environment
- JsonApiDotNetCore Version: 3.1.0
- Other Relevant Package Versions: