Open danaki opened 1 week ago
Update: it seems it has nothing to do with custom Provider/Persister, but with serialization after DeleteMutation(). Obvious normalizationContext and denormalizationContext defining groups has no effect.
#[ApiResource(
processor: DataPersister::class,
provider: DataProvider::class,
normalizationContext: ['groups' => ['delete']],
denormalizationContext: ['groups' => ['delete']],
graphQlOperations: [
new Query(),
new QueryCollection(),
new DeleteMutation(
name: 'delete',
//serialize: false
)
]
)]
class Greeting
{
#[Groups(['delete'])]
private ?string $id = null;
#[Groups(['delete'])]
public string $name = '';
public function __construct($id)
{
$this->id = $id;
$this->name = $id;
}
public function getId(): ?string
{
return $this->id;
}
}
fails with ""Cannot return null for non-nullable field \"Greeting.name\"".
serialize: false (a commented line) helps to avoid error but also gives no output. Issue title updated.
don't you need to do something like https://github.com/api-platform/core/issues/6354 ?
API Plaform: v3.3
Description:
Calling
produces
while name is defined as non-nullable.
Expected behavior:
An output like this:
Entity/Greeting.php
Notice: ApiResource has totaly valid DataPersister and DataProvider defined.
State/DataProvider.php
State/DataPersister.php
Here's the repository reproducing mentioned bug: https://github.com/danaki/api-platform-grapql-delete-mutation-bug-demo