question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Embedded relation without dedicated route

See original GitHub issue

I have a Product entity having a OneToMany relation with a ProductTranslation entity without the “@ApiResource” annotation. I set up the relevant serialization groups for both the normalization_context and the denormalization_context so a GET to /products/ returns as expected:

{
 	"id": 2,
 	"code": "sku123",
 	"translations": [{
 		"id": 12,
 		"name": "Pen",
 		"description": "it is a pen",
 		"locale": "en"
 	}, {
 		"id": 14,
 		"name": "Stylo",
 		"description": "il est un stylo",
 		"locale": "fr"
 	}]
 }

It is working as expected when creating a new object via POST too. My problem is when I try to update a translation via PUT to /products/2:

{
	"code": "sku123",
	"translations": [{
		"id": 12,
		"name": "Biro",
		"description": "it is still a pen",
		"locale": "en"
	}]
}

this would not update the existing relation but just add a new one (another ProductTranslation with another ID). It works as expected if I add the “@ApiResource” annotation to the ProductTranslation entity (and change the translation id to something like “/product_translations/12”) but that would also create an end point for this entity and that is wrong because it is never required to be used directly.

So my question is: is there a way to make the PUT update work for an embedded relation which does not have its own routing / end point?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
soyukacommented, Jan 3, 2017

So those are not associations? If you want the association to be handled by api-platform correctly it should be a Resource.

0reactions
Simperfitcommented, Sep 8, 2017

@esistgut is it ok for you ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Embedded system - Wikipedia
An embedded system is a computer system—a combination of a computer processor, computer memory, and input/output peripheral devices—that has a dedicated ...
Read more >
Programming Embedded Systems, 2nd Edition [Book] - O'Reilly
The design of an embedded system to perform a dedicated function is in direct contrast to that of the personal computer. It too...
Read more >
Managing complexity in embedded systems - McKinsey
Cracking the complexity code in embedded systems development ... Selling hardware without software is unthinkable in most industries.
Read more >
A “One Team” Approach To Recruitment: What Is An ... - Scede
With an embedded talent model, the relationship between the client and the talent partner is more of a collaborative partnership, with mutual ...
Read more >
SRE at Google: How to structure your SRE team - Google Cloud
Easy to get started on an SRE journey without organizational change. ... The work relationship between the embedded SRE(s) and developers ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found