Skip to content

Conversation

jotwea
Copy link
Contributor

@jotwea jotwea commented Nov 8, 2023

Q A
Branch 3.2
Tickets -
License MIT
Doc PR -

We use Doctrine Embeddables in our project. So we also have mutations that contain nested objects. To exclude some properties from beeing modified the writable: false option works fine. But this only worked on the rool level. For nested objects this got ignored. This PR is there to fix that and consider writable: false also for nested objects.

I invested much in writing behat tests that provide a detailed understanding of the issue.

#[ORM\Column(nullable: true)]
public $nonWritableProp;

#[ApiProperty(readableLink: true, writableLink: true)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren't these true already? maybe you should specify serialization groups instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunatelly they are not true by default. If not setting these attributes, there will be a skolem IRI in the JSON instead.

It would be a great behaviour for Embeddables to treat them more like properties than relations. Could you assist in working on that? But I would recommend to tackle this in a separate issue and PR.

Copy link
Member

@soyuka soyuka Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

embeddables were hard to handle previously because if they're marked as a resource the behavior was different. Now I think it'd be possible to do this indeed. agree for another pr

@jotwea jotwea force-pushed the nested-input-writable branch 2 times, most recently from 054d90d to 4215fde Compare November 24, 2023 10:43
@soyuka
Copy link
Member

soyuka commented Nov 24, 2023

the changes in the entity breaks an unrelated test, best would be to create a new entity for this test case (https://github.com/api-platform/core/blob/main/CONTRIBUTING.md#tests)

@jotwea jotwea force-pushed the nested-input-writable branch 2 times, most recently from a32443d to 298f4ed Compare November 25, 2023 12:21
@jotwea jotwea force-pushed the nested-input-writable branch from 298f4ed to 545db3e Compare November 25, 2023 12:31
@jotwea
Copy link
Contributor Author

jotwea commented Nov 25, 2023

the changes in the entity breaks an unrelated test, best would be to create a new entity for this test case (https://github.com/api-platform/core/blob/main/CONTRIBUTING.md#tests)

Fixed it. The other failing tests seem to be already broken in the 3.2 source branch

@soyuka soyuka merged commit 5e8f5eb into api-platform:3.2 Nov 27, 2023
@soyuka
Copy link
Member

soyuka commented Nov 27, 2023

thanks!

@jotwea jotwea deleted the nested-input-writable branch December 11, 2023 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants