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

Relationship URI should be moved to schema relation field #4

Closed
lindyhopchris opened this issue Jan 31, 2021 · 0 comments
Closed

Relationship URI should be moved to schema relation field #4

lindyhopchris opened this issue Jan 31, 2021 · 0 comments

Comments

@lindyhopchris
Copy link
Contributor

At the moment, if you want to use a different convention for a relationship's URI, you have to define it in two places.

Firstly, when registering the route:

$relationships->hasOne('blogPost')->uri('blog_post');

Secondly, on the resource's relation object:

$this->relation('blogAuthor')->retainFieldName()
// or
$this->relation('blogAuthor')->withUriFieldName('blog_author')

Now that we have made resource classes optional, we should move this setting to the schema's relation field. That would mean we could use it both when serializing the relation and when registering routes. (To use it when serializing relations we would need to always inject the schema into the resource class - even if using a specific resource class e.g. PostResource.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant