Skip to content

Update readme about relationships #30

@yairpe

Description

@yairpe

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions