[GraphQL] Output class not respected / working for custom mutations
I have the following annotation in my entity:
* @ApiResource(
* graphql={
* "custom"={
* "args"={},
* "mutation"=MyCustomResolver::class,
* "output"=MyCustomOutput::class
* }
* }
* )
class DummyEntity {
[...]
}
This should result in a GraphQL mutation customDummyEntity with empty args and a result of MyCustomOutput.
First issue which is caused by #2612 is that even though output is set the result gets wrapped in SchemaBuilder and the output class is lost during this.
After setting $useWrappedType to false:
"message": "Cannot query field \"customField\" on type \"myCustomOperationPayload.customField\".",
After setting $wrapData to false:
Custom mutation resolver \"App\\Resolver\\MyCustomResolver\" has to return an item of class DummyEntity but returned an item of class MyCustomOutput.
After disabling that check:
"Cannot return null for non-nullable field myCustomOperationPayload.customField."
@alanpoulain Any suggestions / ideas?
I have created a more general issue (to start a discussion) regarding custom GraphQL operations with more customizability / features #2755 - but would like to get the current implementations working correctly first.
Is there any work around for this issue ? Also any idea when this could be fixed. I am currently hitting dead end with my project because of this issue.
same here... what is even the purpose for the output param in the Mutation operation definition?
Four years and still no solution for this ? oO Is API Platform GraphQL ready for production usage ? oO
Still present in 2025 and 4.0 version 😟
any ideas to fix it ? :)