Comments (2)
Hi David,
Thank you for reporting this
Yes, originally it was designed like this in order to add links to the payload as it is described in the specification:
A “relationship object” MUST contain at least one of the following:
- links
- data
- meta
But I went through the specification and also checked the code once again. And I discovered that the links
object doesn't require the relationship itself to be populated. You can check that here https://github.com/tuyakhov/yii2-json-api/blob/master/src/ResourceTrait.php#L94
Please correct me if I wrong, but I think that avoiding pre-population is something that could be implemented easily. It gets a bit tricky if we want to support dot-separated path, like ?include=comments.author
from yii2-json-api.
Hi Anton,
Yes, I think you're looking at it right. In fact, I think we should be able to support either related links (as we're doing) or allow users to generate direct links (i.e. /api/authors/1
) without loading the relationship (as it's possible to use the $blog->author_id
instead of $blog->author->primaryKey
)
But yes, I think we do want to support ?include=comments.author
relationships as well (I hit a need for that yesterday 😀 ). For that's where the power of the includes system really comes into play ...
from yii2-json-api.
Related Issues (20)
- Sparse filedsets: query naming problem. HOT 7
- Default REST doesn't work HOT 2
- Can't create resource without relationships. HOT 1
- Is there any demo/example of how to use this extension? HOT 6
- Add an ActiveRecordInterface that allows using form models? HOT 2
- feature request - support JSONAPI filetring
- Errors format is not compatible with JSONAPI HOT 3
- Update readme about relationships HOT 3
- Field name should be convert according to recommendations for JSON API implementations HOT 1
- Have question about relationships. HOT 10
- Include relationship object in every response (even when omitted from include) HOT 1
- It is impossible to clear the relations by sending PATCH request to relationship link. HOT 2
- Require "data" key when fetching data and deleting resouce HOT 6
- Allow addition of relationship information without full include data HOT 2
- Note which versions of PHP we support? HOT 3
- moving away from unlink/unlinkAll/link HOT 1
- unlink delete parameter HOT 1
- Authentication and authorization HOT 1
- Update many to many relation not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii2-json-api.