core icon indicating copy to clipboard operation
core copied to clipboard

When having GraphQL, an exception occurs when Twig is not enabled

Open rvanlaak opened this issue 3 years ago • 2 comments

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.

image

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: image

rvanlaak avatar Aug 16 '22 11:08 rvanlaak

I think that this was already the case on API P 2.6 no ?

soyuka avatar Sep 16 '22 13:09 soyuka

Possibly, yes. But won't have the resources to verify this, as we are working on adopting 3.x

rvanlaak avatar Sep 19 '22 12:09 rvanlaak

I guess #5064 fixes that

soyuka avatar Oct 17 '23 09:10 soyuka