8000 Relationships are not updated in a PATCH response · Issue #125 · cloudcreativity/laravel-json-api · GitHub
[go: up one dir, main page]

Skip to content
Relationships are not updated in a PATCH response #125
Closed
@danherd

Description

@danherd

As the title says, really. For example:

GET /employees/

{
	"data": {
		"type": "employees",
		"id": "<id>",
		"attributes": {
			"first-name": "Scott",
			"last-name": "Jones",
			"full-name": "Scott Jones",
		},
		"relationships": {
			"permissions": {
				"data": []
			}
		},
		"links": {
			"self": "https://api.dev/employees/<id>"
		}
	}
}

PATCH /employees/

Request:

{
	"data": {
	"type": "employees",
	"id": "<id>",
		"attributes": {
			"first-name": "Jim",
			"last-name": "Brown"
		},
		"relationships": {
			"permissions": {
				"data": [
					{ "type": "permissions", "id": "practicegroup-employees" },
					{ "type": "permissions", "id": "practicegroup-practices" }
				]
			}
		}
	}
}

Response:

{
	"data": {
		"type": "employees",
		"id": "<id>",
		"attributes": {
			"first-name": "Jim",
			"last-name": "Brown",
			"full-name": "Jim Brown",
		},
		"relationships": {
			"permissions": {
				"data": []
			}
		},
		"links": {
			"self": "https://api.dev/employees/<id>"
		}
	}
}

GET /employees/

{
	"data": {
		"type": "employees",
		"id": "<id>",
		"attributes": {
			"first-name": "Jim",
			"last-name": "Brown",
			"full-name": "Jim Brown",
		},
		"relationships": {
			"permissions": {
				"data": [
					{ "type": "permissions", "id": "practicegroup-employees" },
					{ "type": "permissions", "id": "practicegroup-practices" }
				]
			}
		},
		"links": {
			"self": "https://api.dev/employees/<id>"
		}
	}
}

Why do the attributes come through updated, but the relationships do not?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0