core
core copied to clipboard
When having GraphQL, an exception occurs when Twig is not enabled
API Platform version(s) affected: 3.0.0-rc.2
Description
The API Platform GraphiQL integration seems to have a dependency on the twig service, but that leads to an compilation exception when Twig is not enabled for the active environment.
How to reproduce
- require webonyx/graphql-php to enable GraphQL for api-platform
- but do not enable TwigBundle in bundles.php for the active environment (e.g.
prod).
Possible Solution
Do not enable the visual graphiQL playground when Twig service is not available or bundle is not enabled.
Additional Context
see documentation https://api-platform.com/docs/core/graphql/#graphiql
Our use-case is that we do not want to have Twig enabled on our prod environment because we only support json and xml content types.
- Enabling TwigBundle in bundles.php for all environments solves the exception but is not preferable
- Disabling graphiql does not solve the exception:

I think that this was already the case on API P 2.6 no ?
Possibly, yes. But won't have the resources to verify this, as we are working on adopting 3.x
I guess #5064 fixes that