8000 Allow adding links to Relationship Object · Issue #166 · laravel-json-api/laravel · GitHub
[go: up one dir, main page]

Skip to content
Allow adding links to Relationship Object #166
Open
@LeeJump24

Description

@LeeJump24

Is it possible to add a link to a relationship? So add a link to the firstQuestion

"relationships": {
  "questions": {
    "links": {
      "firstQuestion": "http://localhost/api/v1/questions/616c98f8-3ea9-4bb2-8152-3dd40c3846eb",
      "related": "http://localhost/api/v1/surveys/4b732db9-48da-43c9-bec0-6df2dc7dcbe3/questions",
      "self": "http://localhost/api/v1/surveys/4b732db9-48da-43c9-bec0-6df2dc7dcbe3/relationships/questions"
    }
  }
}

I'm not an expert on the spec but reading https://jsonapi.org/format/#document-resource-object-relationships sounds like it should be allowed? We can add extra links to other link objects.

Full example

{
  "jsonapi": {
    "version": "1.0"
  },
  "links": {
    "self": "http://localhost/api/v1/surveys/4b732db9-48da-43c9-bec0-6df2dc7dcbe3"
  },
  "data": {
    "type": "surveys",
    "id": "4b732db9-48da-43c9-bec0-6df2dc7dcbe3",
    "attributes": {
      "name": "Survey A",
      "description": "Description of Survey A"
    },
    "relationships": {
      "questions": {
        "links": {
          "firstQuestion": "http://localhost/api/v1/questions/616c98f8-3ea9-4bb2-8152-3dd40c3846eb",
          "related": "http://localhost/api/v1/surveys/4b732db9-48da-43c9-bec0-6df2dc7dcbe3/questions",
          "self": "http://localhost/api/v1/surveys/4b732db9-48da-43c9-bec0-6df2dc7dcbe3/relationships/questions"
        }
      }
    },
    "links": {
      "self": "http://localhost/api/v1/surveys/4b732db9-48da-43c9-bec0-6df2dc7dcbe3"
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0