Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Proposal: Change key 'resource' to 'relation' in hasOne/hasMany object param. #95

@aars

Description

@aars

If it's still the case that the optional {resource: 'direct-reports', type: 'employees'} isn't documented (much/well) I want to suggest to rename the resource property of that object to relation. So:

Resource.extend({
  directReports: hasMany({relation: 'direct-reports', type: 'employees'}), // suggested
  // directReports: hasMany({resource: 'direct-reports', type: 'employees'}) // current
});

2 reasons:

  1. Calling it resource is confusing since we're defining Resources all over the place, but that is not what it means in this case.
  2. The related-proxy stores this value as relation. Which is what we end up using internally. meta.relation.

Many times there isn't really a resource (either defined in terms of ember-jsonapi-resources or defined in terms of a JSONAPI url/resource to request) by this name. It is the name of the relationship a Resource has with some other Resource of a certain type. As defined by type.
To illustrate using urls:
http://api.pixelhandler.com/api/v1/supervisors/1/relationships/`resource`
vs
http://api.pixelhandler.com/api/v1/supervisors/1/relationships/`relation`
would make more sense since:
http://api.pixelhandler.com/api/v1/direct-reports does not exist. It is not a resource.

(I'll be happy to do the work for this. Including changes to docs)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions