JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

Links not accurate for nested resource

Open
#970 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
2.3k
Forks
546
PR merge metrics
No merged PRs in 30d

Description

I'm writing a multi-tenant application where absolutely every request has to have a location ID as part of the URL or as a param. How do I make it so that when I POST to a nested resource, like to /locations/{location ID}/contacts, the item I get back includes a link that looks like /locations/{location ID}/contacts/{contact ID}? Right now the links returned from the API are just /contacts/{contact ID}, but this won't work because IDs aren't guaranteed to be unique across locations.

Is there a way for the nesting of resources to only go one way like this?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how the POST response builds links for the nested /locations/{location ID}/contacts endpoint and compare them with the returned /contacts/{contact ID} links. Determine where parent-resource context is lost and define tests that verify the location ID is retained in generated links without changing unrelated resource paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.