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

Update readme about relationships #30

Open
yairpe opened this issue Jul 6, 2017 · 3 comments
Open

Update readme about relationships #30

yairpe opened this issue Jul 6, 2017 · 3 comments
Milestone

Comments

@yairpe
Copy link

yairpe commented Jul 6, 2017

In general, it is not clear what parts of jsonapi standard is covered by the extension and what is left for the implementor or maybe will be included in future updates of the extension.

There are two areas in specific that are not covered by the readme:

  1. resources and sub-resources

For example, the readme says nothing that it uses eaxtraFields() in the parent model to allow the use of ?include=child. I had to extract it from the sources.
i.e in Countries.php

    public function extraFields()
    {
        return ['cities']
    }
    public function getCities()
    {
        return $this->hasMany(Cities::className(), ['country_id' => 'id']);
    }

and in Cities.php

    public function getLinks()
    {
        return [
            Url::home(true) . 'v1/cities/' . $this->id,
        ];
    }

to be able to use something like v1/countries/10?include=cities

  1. Relationships
    It is not clear how they work and how to use them. What is covered? just serializing the output? or more than that since the source have UpdateRelationshipAction.php?

In short, some more info with usage examples would be much welcomed

@tuyakhov
Copy link
Owner

tuyakhov commented Jul 8, 2017

  1. Almost everything from jsonapi standard is covered in this extension, except for filtering and sorting. Mostly because JSON API is agnostic about the strategies supported by a server. It only requires using the filter, sort query parameters for filtering/sorting operations.
    But despite that, I am currently working on those 2 parts, in order to provide support of some basic operations.
  2. Apart from serializing the output, updating relationships are supported as well. And it works as described in specification so that you can modify relationships along with resources (http://jsonapi.org/format/#crud-updating-resource-relationships) or by hitting the independent URL (http://jsonapi.org/format/#crud-updating-relationships) in this case you have to use UpdateRelationshipAction.php

@mtangoo
Copy link

mtangoo commented Jul 8, 2017

I was thinking about forking ember's rental store and make Yii2 API as BE.
unfortunately I don't have any time in hand currently. But someone can pick that and make it a reality. It will serve as good example

https://github.com/ember-learn/super-rentals

@yairpe
Copy link
Author

yairpe commented Jul 21, 2017

Almost everything from jsonapi standard is covered in this extension, except for filtering and sorting. Mostly because JSON API is agnostic about the strategies supported by a server. It only requires using the filter, sort query parameters for filtering/sorting operations.
But despite that, I am currently working on those 2 parts, in order to provide support of some basic operations.

Great, waiting for it. It's much better to have it as part of the extension rather than individual implementations in several places.

Thank you Anton

@tuyakhov tuyakhov added this to the v1.0.0 milestone Apr 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants